I keep getting this error " NoMethodError:undefined method `visit' for #<RSpec::ExampleGroups::" in rspec and rails 4.1 -
i'm working on http://net.tutsplus.com/tutorials/ruby/the-intro-to-rails-screencast-i-wish-i-had/ , keep getting error.
i'm using rails 4.1
terminal
failures: 1) tasks /tasks display task failure/error: visit tasks_path nomethoderror: undefined method `visit' #<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 /tasks creates new task failure/error: visit "/" nomethoderror: undefined method `visit' #<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 load) 4 examples, 2 failures, 2 pending failed examples: rspec ./spec/features/task_spec.rb:5 # tasks /tasks display task rspec ./spec/features/task_spec.rb:12 # tasks /tasks creates new task i tried "features/task_spect.rb" , "requests/tasks_spect.rb"
require "rails_helper" rspec.describe "tasks", type: :request describe "get /tasks" "display task" @task = task.create :task => "go bed" visit tasks_path page.should have_content "go bed" end "creates new task" visit "/" fill_in "task", :with => "go work" click_button "create task" current_path.should == root_path page.should have_content "go work" save_and_open_page end end end gems
group :development, :test gem 'rspec-rails' gem 'capybara' end new rspec.rb
require 'rails_helper' rspec.describe "tasks", type: :request config.include capybara::dsl describe "get /tasks" "display task" @task = task.create :task => 'go bed' visit root_path page.should have_content 'go bed' end "creates new task" visit '/' fill_in 'task', :with => 'go work' click_button 'create task' current_path.should == task_path page.should have_content 'go work' save_and_open_page end end end
i have fixed error , post in github app
https://github.com/rajcybage/tasks
please see commit
https://github.com/rajcybage/tasks/commit/fa6fa54e60717f805e040f0eb767dc0e3ef4d434
run 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 seed 14426 .. deprecation warnings: requiring `rspec/autorun` when running rspec via `rspec` command deprecated. called /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` rspec-expectations' old `:should` syntax without explicitly enabling syntax deprecated. use new `:expect` syntax or explicitly enable `:should` `config.expect_with(:rspec) { |c| c.syntax = :should }` instead. called /home/rajarshi/tasks/spec/features/task_spec.rb:18:in `block (3 levels) in <top (required)>'. if need more of backtrace of these deprecations identify make necessary changes, can configure `config.raise_errors_for_deprecations!`, , turn deprecation warnings errors, giving full backtrace. 2 deprecation warnings total finished in 2.06 seconds (files took 6.03 seconds load) 2 examples, 0 failures randomized seed 14426 rajarshi@rajarshi-x200ca:~/tasks$
Comments
Post a Comment