title: Rspec Controller testing with Javascript
body: <p>How do you test a controller in Rspec if the controller only responds with javascript? For example this would be my actual code:</p>
  
  <p>some view.html.erb</p>
  
  <pre><code>link_to 'More Chips', add_chips_path, :remote =&gt; true
  </code></pre>
  
  <p>chips_controller</p>
  
  <pre><code>def add_chips
    Chips.create(:color =&gt; :red)
    @chips = Chips.all
  end
  </code></pre>
  
  <p>add_chips.js.erb</p>
  
  <pre><code>$('#chip_count').html('&lt;%=j render("chips/list", :chips =&gt; @chips) %&gt;');
  </code></pre>
  
  <p>Rspec Test</p>
  
  <p>spec/controllers/chips_controller_spec</p>
  
  <pre><code>it "should add chips" do 
    post :add_chips, :format =&gt; 'js'
  end
  </code></pre>
  
  <p>When I try to post to this using RSpec I get a Missing Template error because it is sending an HTML request but there isn't an HTML view. I've tried passing in a format but that doesn't seem to work.  I know I can put in a "dummy" html view to make it pass but that seems like a hack.</p>
  
  <p>Thanks</p>