I'm working on this http://net.tutsplus.com/tutorials/ruby/the-intro-to-rails-screencast-i-wish-i-had/ and I keep getting this error.
I'm using rails 4.1
terminal
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
I tried "features/task_spect.rb" and "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
gems
group :development, :test do
gem 'rspec-rails'
gem 'capybara'
end
new 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