title: Jasmine - Checking addClass on click
body: <p>This is a Rails app. I'm using the Jasmine gem with Jasmine-Jquery.</p>
  
  <p>Here's my JS in asset pipeline:</p>
  
  <pre><code>$selector = function() {
      $('#filters li').click(function() {
          $('#filters li').siblings().removeClass('selected');
          $(this).addClass('selected');
      });
  }
  $selector();
  </code></pre>
  
  <p>Here's my fixture called workgrid_spec.html:</p>
  
  <pre><code>&lt;div class="row"&gt;
      &lt;div class="large-12 columns"&gt;
          &lt;ul id="filters"&gt;
              &lt;li class="identity" data-filter=".identity"&gt;Identity&lt;/li&gt;
              &lt;li&gt;//&lt;/li&gt;
              &lt;li data-filter=".print"&gt;Print&lt;/li&gt;
              &lt;li&gt;//&lt;/li&gt;
              &lt;li data-filter=".web"&gt;Web&lt;/li&gt;
              &lt;li&gt;//&lt;/li&gt;
              &lt;li data-filter=".video"&gt;Video&lt;/li&gt;
              &lt;li&gt;//&lt;/li&gt;
              &lt;li class="selected" data-filter="*"&gt;See All&lt;/li&gt;
          &lt;/ul&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And here's my spec file:</p>
  
  <pre><code>describe("Make sure the workgrid works right", function() {    
      beforeEach(function() {
          loadFixtures('workgrid_spec.html');    
      });    
      describe("when a filter is clicked", function() {   
          it("is highlighted in the list with the 'selected' class", function() {
              $('.identity').click();
              expect('.identity').toHaveClass('selected');
          });    
      });
  });
  </code></pre>
  
  <p>And here's the error I'm getting:</p>
  
  <pre><code>Error: Expected '.identity' to have class 'selected'.
      at new jasmine.ExpectationResult (http://localhost:8888/__jasmine__/jasmine.js:114:32)
      at null.toHaveClass (http://localhost:8888/__jasmine__/jasmine.js:1235:29)
      at null.&lt;anonymous&gt; (http://localhost:8888/__spec__/workgrid_spec.js:12:24)
  </code></pre>