I'm following the Ruby on Rails tutorial and ran into the following problem:
me@me:~/Ruby/sample_app$ bundle exec rspec spec/requests/static_pages_spec.rb
F
Failures:
1) Static pages Home page should have the content 'Sample App' Failure/Error: visit '/static_pages/home'
NoMethodError:
undefined method `visit' for #<RSpec::ExampleGroups::StaticPages::HomePage:0x00000001e1df88>
# ./spec/requests/static_pages_spec.rb:8:in `block (3 levels) in <top (required)>'
Finished in 0.0006 seconds (files took 0.08149 seconds to load) 1 example, 1 failure
Failed examples:
rspec ./spec/requests/static_pages_spec.rb:7 # Static pages Home page should have the content 'Sample App'
Here is my Gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
group :development, :test do
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
gem 'rspec-rails'
end
group :assets do
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
end
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
group :test do
gem 'capybara'
end
group :prodcution do
gem 'pg'
end
My spec/requests/static_pages_spec.rb:
require 'spec_helper'
describe "Static pages" do
describe "Home page" do
it "should have the content 'Sample App'" do
visit '/static_pages/home'
page.should have_content('Sample App')
end
end
end
Digging up online suggested putting config.include Capybara::DSL in spec/spec_helper.rb. I did that and didn't work. Another suggestion said I need to move my static_pages_spec.rb to spec/features. I did that and that didn't work either.
Help? :D