views:

71

answers:

2

I am following the examples in the Rails Tutorial website and I'm having issues getting the integration tests to work. Specifically the example at listing 8.20 in section 8.4.2 in the tutorial.

At the visit signup_path line of code below I get the following error: "undefined local variable or method `signup_path'"

require 'spec_helper'

describe "Users" do
  describe "signup" do
    describe "failure" do
      it "should not make a new user" do
        visit signup_path
        fill_in "Name", :with => ""
        fill_in "Email", :with => ""
        fill_in "Password", :with => ""
        fill_in "Confirmation", :with => ""
        click_button
        response.should render_template("users/new")
        response.should have_selector("div#error_explanation")
      end
    end
  end
end

Here's the full test file on github

However, if I run all the tests at once, then I do not get the error. The error only happens when I run that individual test.

My project can be viewed on github here

How do I fix this error?

A: 

What commands are you using to run all of the specs and just one spec. Please list the full command (e.g. bundle exec rspec spec/requests).

David Chelimsky
I'm using autotest
Paul
A: 

You are supposed to change the test according to listing 8.21. The test would then look like this:

spec/requests/users_spec.rb:

require 'spec_helper'

describe "Users" do
  describe "signup" do
    describe "failure" do
      it "should not make a new user" do
        lambda do
          get signup_path
          fill_in "Name", :with => ""
          fill_in "Email", :with => ""
          fill_in "Password", :with => ""
          fill_in "Confirmation", :with => ""
          click_button "Sign up"
          response.should have_selector("div#error_explanation")
        end.should_not change(User, :count)
      end
    end
  end
end
Daniel Lidström