开发者

having problems with "visit" in integration tests on the rails tutorial

I am new to rails and am running through the rails 3 tutorial. I have a problem running integration tests. It seems that the method 'visit' (Webrat?) will always fail. This is the kind of error message I get from rspec:

Failure/Error: visit signup_path
Unknown Webrat mode: nil

Please ensure you have a Webrat configuration block that specifies a mode
in your test_helper.rb, spec_helper.rb, or env.rb (for Cucumber).

This configure block supercedes the need to require "webrat/<framework>".

For example:

  Webrat.configure do |config|
    config.mode = :rails
  end
# ./spec/requests/users_spec.rb:27:in `block (5 levels) in <top (required)>'
# ./spec/requests/users_spec.rb:26:in `block (4 levels) in <top (required)>'

I tried adding the Webrat configure block above to spec/spec_helpers.rb, and I get t开发者_JAVA百科his error:

Failure/Error: visit signup_path
no such file to load -- action_controller/integration
# ./spec/requests/users_spec.rb:27:in `block (5 levels) in <top (required)>'
# ./spec/requests/users_spec.rb:26:in `block (4 levels) in <top (required)>'

I have read other topics about this problem and they suggested using 'config.mode = :rack', if I do so then I get this error:

Failure/Error: visit signup_path
undefined method `last_response' for #<RSpec::Core::ExampleGroup::Nested_5::Nested_1::Nested_2:0xa4b8aac>
# ./spec/requests/users_spec.rb:27:in `block (5 levels) in <top (required)>'
# ./spec/requests/users_spec.rb:26:in `block (4 levels) in <top (required)>'

I guess it might be important to note that I started the tutorial on win7x64, but I tried cloning the repository on ubuntu with the same errors. Here is the repository if anyone wants a look:

git://github.com/ender4/sample_app2.git note the 2 there^

I have read a lot of similar topics but most solutions are for older versions of rails/rspec/webrat or for other testing frameworks (like cucumber) and so I do not know if/how they would apply.

Any help would be appreciated.


If you see failures:

  1. User signup failure should not make a new user Failure/Error: visit signup_path NameError: undefined local variable or method `signup_path' for #RSpec::Core::ExampleGroup::Nested_1::Nested_3::Nested_1:0x0000000272d5b0

... Make sure you are placing the test(s) in the correct file:

it belongs in: /spec/requests/users_spec.rb not in: /spec/model/user_spec.rb

Learn by doing and all that! :0 <> ... much easier to watch the other guy slam into a wall and then avoid that path! :)


updated gems to :

group :development do
  gem 'rspec-rails', '2.4.1'
end

group :test do
  gem 'rspec', '2.4.0'
  gem 'webrat', '0.7.1'
end

works!


I think I found the culprit, rspec 2.2.0. Using rspec 2.1.0 seems to fix the problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜