I keep getting this error " NoMethodError:undefined method `visit' for #<RSpec::ExampleGroups::" in rspec and rails 4.1
I keep getting this error " NoMethodError:undefined method `visit' for #<RSpec::ExampleGroups::" in rspec and rails 4.1
我正在处理此问题 http://net.tutsplus.com/tutorials/ruby/the-intro-to-rails-screencast-i-wish-i-had/,但我一直收到此错误。
我正在使用 rails 4.1
航站楼
Failures:
1) Tasks GET /tasks display some task
Failure/Error: visit tasks_path
NoMethodError:
undefined method `visit' for #<RSpec::ExampleGroups::Tasks::GETTasks:0x007fcfbd633758>
# /Users/estebangallego/.rvm/gems/ruby-2.2.0/gems/actionpack-4.1.8/lib/action_dispatch/testing/assertions/routing.rb:171:in `method_missing'
# /Users/estebangallego/.rvm/gems/ruby-2.2.0/gems/actionpack-4.1.8/lib/action_dispatch/testing/integration.rb:396:in `method_missing'
# ./spec/features/task_spec.rb:7:in `block (3 levels) in <top (required)>'
2) Tasks GET /tasks creates a new task
Failure/Error: visit "/"
NoMethodError:
undefined method `visit' for #<RSpec::ExampleGroups::Tasks::GETTasks:0x007fcfbe572ea8>
# /Users/estebangallego/.rvm/gems/ruby-2.2.0/gems/actionpack-4.1.8/lib/action_dispatch/testing/assertions/routing.rb:171:in `method_missing'
# /Users/estebangallego/.rvm/gems/ruby-2.2.0/gems/actionpack-4.1.8/lib/action_dispatch/testing/integration.rb:396:in `method_missing'
# ./spec/features/task_spec.rb:13:in `block (3 levels) in <top (required)>'
Finished in 0.01248 seconds (files took 1.69 seconds to load)
4 examples, 2 failures, 2 pending
Failed examples:
rspec ./spec/features/task_spec.rb:5 # Tasks GET /tasks display some task
rspec ./spec/features/task_spec.rb:12 # Tasks GET /tasks creates a new task
我尝试了 "features/task_spect.rb" 和 "requests/tasks_spect.rb"
require "rails_helper"
RSpec.describe "Tasks", type: :request do
describe "GET /tasks" do
it "display some task" do
@task = Task.create :task => "go to bed"
visit tasks_path
page.should have_content "go to bed"
end
it "creates a new task" do
visit "/"
fill_in "Task", :with => "go to work"
click_button "Create Task"
current_path.should == root_path
page.should have_content "go to work"
save_and_open_page
end
end
end
宝石
group :development, :test do
gem 'rspec-rails'
gem 'capybara'
end
新rspec.rb
require 'rails_helper'
RSpec.describe "Tasks", type: :request do
config.include Capybara::DSL
describe "GET /tasks" do
it "display some task" do
@task = Task.create :task => 'go to bed'
visit root_path
page.should have_content 'go to bed'
end
it "creates a new task" do
visit '/'
fill_in 'Task', :with => 'go to work'
click_button 'Create Task'
current_path.should == task_path
page.should have_content 'go to work'
save_and_open_page
end
end
end
我已在我的 github 应用程序中 post 修复了错误
https://github.com/rajcybage/tasks
请查看提交
https://github.com/rajcybage/tasks/commit/fa6fa54e60717f805e040f0eb767dc0e3ef4d434
运行 bundle exec rake spec:features
rajarshi@rajarshi-X200CA:~/tasks$ bundle exec rake spec:features
/home/rajarshi/.rbenv/versions/2.1.4/bin/ruby -I/home/rajarshi/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.3/lib:/home/rajarshi/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rspec-support-3.2.2/lib /home/rajarshi/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.3/exe/rspec --pattern ./spec/features/\*\*/\*_spec.rb
Randomized with seed 14426
..
Deprecation Warnings:
Requiring `rspec/autorun` when running RSpec via the `rspec` command is deprecated. Called from /home/rajarshi/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `require'.
Using `should` from rspec-expectations' old `:should` syntax without explicitly enabling the syntax is deprecated. Use the new `:expect` syntax or explicitly enable `:should` with `config.expect_with(:rspec) { |c| c.syntax = :should }` instead. Called from /home/rajarshi/tasks/spec/features/task_spec.rb:18:in `block (3 levels) in <top (required)>'.
If you need more of the backtrace for any of these deprecations to
identify where to make the necessary changes, you can configure
`config.raise_errors_for_deprecations!`, and it will turn the
deprecation warnings into errors, giving you the full backtrace.
2 deprecation warnings total
Finished in 2.06 seconds (files took 6.03 seconds to load)
2 examples, 0 failures
Randomized with seed 14426
rajarshi@rajarshi-X200CA:~/tasks$
我正在处理此问题 http://net.tutsplus.com/tutorials/ruby/the-intro-to-rails-screencast-i-wish-i-had/,但我一直收到此错误。
我正在使用 rails 4.1
航站楼
Failures:
1) Tasks GET /tasks display some task
Failure/Error: visit tasks_path
NoMethodError:
undefined method `visit' for #<RSpec::ExampleGroups::Tasks::GETTasks:0x007fcfbd633758>
# /Users/estebangallego/.rvm/gems/ruby-2.2.0/gems/actionpack-4.1.8/lib/action_dispatch/testing/assertions/routing.rb:171:in `method_missing'
# /Users/estebangallego/.rvm/gems/ruby-2.2.0/gems/actionpack-4.1.8/lib/action_dispatch/testing/integration.rb:396:in `method_missing'
# ./spec/features/task_spec.rb:7:in `block (3 levels) in <top (required)>'
2) Tasks GET /tasks creates a new task
Failure/Error: visit "/"
NoMethodError:
undefined method `visit' for #<RSpec::ExampleGroups::Tasks::GETTasks:0x007fcfbe572ea8>
# /Users/estebangallego/.rvm/gems/ruby-2.2.0/gems/actionpack-4.1.8/lib/action_dispatch/testing/assertions/routing.rb:171:in `method_missing'
# /Users/estebangallego/.rvm/gems/ruby-2.2.0/gems/actionpack-4.1.8/lib/action_dispatch/testing/integration.rb:396:in `method_missing'
# ./spec/features/task_spec.rb:13:in `block (3 levels) in <top (required)>'
Finished in 0.01248 seconds (files took 1.69 seconds to load)
4 examples, 2 failures, 2 pending
Failed examples:
rspec ./spec/features/task_spec.rb:5 # Tasks GET /tasks display some task
rspec ./spec/features/task_spec.rb:12 # Tasks GET /tasks creates a new task
我尝试了 "features/task_spect.rb" 和 "requests/tasks_spect.rb"
require "rails_helper"
RSpec.describe "Tasks", type: :request do
describe "GET /tasks" do
it "display some task" do
@task = Task.create :task => "go to bed"
visit tasks_path
page.should have_content "go to bed"
end
it "creates a new task" do
visit "/"
fill_in "Task", :with => "go to work"
click_button "Create Task"
current_path.should == root_path
page.should have_content "go to work"
save_and_open_page
end
end
end
宝石
group :development, :test do
gem 'rspec-rails'
gem 'capybara'
end
新rspec.rb
require 'rails_helper'
RSpec.describe "Tasks", type: :request do
config.include Capybara::DSL
describe "GET /tasks" do
it "display some task" do
@task = Task.create :task => 'go to bed'
visit root_path
page.should have_content 'go to bed'
end
it "creates a new task" do
visit '/'
fill_in 'Task', :with => 'go to work'
click_button 'Create Task'
current_path.should == task_path
page.should have_content 'go to work'
save_and_open_page
end
end
end
我已在我的 github 应用程序中 post 修复了错误
https://github.com/rajcybage/tasks
请查看提交
https://github.com/rajcybage/tasks/commit/fa6fa54e60717f805e040f0eb767dc0e3ef4d434
运行 bundle exec rake spec:features
rajarshi@rajarshi-X200CA:~/tasks$ bundle exec rake spec:features
/home/rajarshi/.rbenv/versions/2.1.4/bin/ruby -I/home/rajarshi/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.3/lib:/home/rajarshi/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rspec-support-3.2.2/lib /home/rajarshi/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.3/exe/rspec --pattern ./spec/features/\*\*/\*_spec.rb
Randomized with seed 14426
..
Deprecation Warnings:
Requiring `rspec/autorun` when running RSpec via the `rspec` command is deprecated. Called from /home/rajarshi/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `require'.
Using `should` from rspec-expectations' old `:should` syntax without explicitly enabling the syntax is deprecated. Use the new `:expect` syntax or explicitly enable `:should` with `config.expect_with(:rspec) { |c| c.syntax = :should }` instead. Called from /home/rajarshi/tasks/spec/features/task_spec.rb:18:in `block (3 levels) in <top (required)>'.
If you need more of the backtrace for any of these deprecations to
identify where to make the necessary changes, you can configure
`config.raise_errors_for_deprecations!`, and it will turn the
deprecation warnings into errors, giving you the full backtrace.
2 deprecation warnings total
Finished in 2.06 seconds (files took 6.03 seconds to load)
2 examples, 0 failures
Randomized with seed 14426
rajarshi@rajarshi-X200CA:~/tasks$