Martinicity: Tag testingMike Blaketag:www.martinicity.net,2005:TypoTypo2007-02-19T18:27:18+00:00Mike Blakeurn:uuid:6ddf5409-4a21-4502-a1d6-b9dc8733aedc2007-02-19T18:23:00+00:002007-02-19T18:27:18+00:00Undefined method assert_select<p>The <a href="http://blog.labnotes.org/2006/09/04/assert_select-cheat-sheet/">assert_select</a> method for testing views was added in <a href="http://weblog.rubyonrails.org/2006/11/26/1-2-new-in-actionpack">Rails 1.2</a>, so the first thing to check if you’re getting the error below is that you’ve upgraded to 1.2</p>
<pre>
> 2) Error:
>test_expire_old_ads(AdExpirationTest):
>NoMethodError: undefined method `assert_select' for #<ActionController::Integration::Session:0x378ae98>
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/test_process.rb:432:in `method_missing'
</pre>
<p>Now I upgraded to 1.2 and still kept getting the above error. The problem was that my application was set to use Rails 1.1.6 in the config/environment.rb file:</p>
<div class="typocode"><pre><code class="typocode_ruby "><span class="comment"># Specifies gem version of Rails to use when vendor/rails is not present</span>
<span class="constant">RAILS_GEM_VERSION</span> <span class="punct">=</span> <span class="punct">'</span><span class="string">1.1.6</span><span class="punct">'</span></code></pre></div>
<p>So the solution is to comment out that line, or alternatively ,set it to the latest version. Also make sure you’re not frozen to a specific Rails version in the vendor directory.</p>