Note that there are some explanatory texts on larger screens.

plurals
  1. POget method for testing in rails
    text
    copied!<p>I'm following along with <a href="http://railsspace.com" rel="nofollow noreferrer">RailsSpace: Building a Social Networking Website with Ruby on Rails by Michael Hartl</a>. Running rails v2.3.2.</p> <p>I've gotten to the 5th chapter in which testing is introduced. The following is supposed to match the title of the various pages to strings using the get method:</p> <pre><code>require File.dirname(__FILE__) + '/../test_helper' require 'site_controller' # Re-raise errors caught by the controller. class SiteController; def rescue_action(e) raise e end; end class SiteControllerTest &lt; Test::Unit::TestCase def setup @controller = SiteController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new end def test_index get :index title = assigns(:title) assert_equal "Welcome to RailsSpace!", title assert_response :success assert_template "index" end def test_about get :title title = assigns(:title) assert_equal "About RailsSpace", title assert_response :success assert_template "about" end def test_help get :help title = assigns(:title) assert_equal "RailsSpace Help", title assert_response :success assert_template "help" end end </code></pre> <p>On compiling I get:</p> <pre><code>Loaded suite site_controller_test Started EEE Finished in 0.057 seconds. 1) Error: test_about(SiteControllerTest): NoMethodError: undefined method `get' for #&lt;SiteControllerTest:0x4854b30&gt; site_controller_test.rb:23:in `test_about' 2) Error: test_help(SiteControllerTest): NoMethodError: undefined method `get' for #&lt;SiteControllerTest:0x4854b1c&gt; site_controller_test.rb:31:in `test_help' 3) Error: test_index(SiteControllerTest): NoMethodError: undefined method `get' for #&lt;SiteControllerTest:0x485470c&gt; site_controller_test.rb:15:in `test_index' 3 tests, 0 assertions, 0 failures, 3 errors </code></pre> <p>Other people have had <a href="http://groups.google.com/group/railsspace/browse_thread/thread/2d31abab46f25f38" rel="nofollow noreferrer">this issue</a> and the only proposed solution is just to reinstall. I'm not to enthused by this. Since this is an older book there this is probably just breakage between rails versions. What would be the equivalent of this for rails v2.3.2?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload