title: How do I test fulltext fields using sunspot_matchers in rspec?
body: <p>My search controller does this:</p>
  
  <pre><code>search = Sunspot.search(Item) do
    fulltext params[:q] do
      fields(:foo, :bar, :bletch)
    end
  end
  </code></pre>
  
  <p>And in my rspec controller test I have the following:</p>
  
  <pre><code>get :show, :q =&gt; q
  
  expect(Sunspot.session).to have_search_params(:fulltext, q, proc do
    fields(:foo, :bar, :bletch)
  end)
  </code></pre>
  
  <p>Side note: when I tried using a block instead of a proc, the block was never executed:</p>
  
  <pre><code>have_search_params(:fulltext, q) do
    # This block was never executed
  end
  </code></pre>
  
  <p>My support/sunspot.rb contains only the following:</p>
  
  <pre><code>Sunspot.session = SunspotMatchers::SunspotSessionSpy.new(Sunspot.session)
  </code></pre>
  
  <p>When I run the test, I get the following error:</p>
  
  <pre><code>  1) SearchController GET search when a user runs a search performs a fulltext search on the right fields
       Failure/Error: fields(:foo, :bar, :bletch)
       NoMethodError:
         undefined method `fields' for #&lt;Sunspot::DSL::Search:0x007fa0f0da0168&gt;
       # ./spec/controllers/search_controller_spec.rb:28:in `block (5 levels) in &lt;top (required)&gt;'
       # ./spec/controllers/search_controller_spec.rb:27:in `block (4 levels) in &lt;top (required)&gt;'
  </code></pre>
  
  <p>What's the right way to test that my controller is supplying the correct params when doing a fulltext search? Google yields no relevant results when querying this problem.</p>