I have install rspec-rails like this and create a file static_pages_spec.rb
gem list
272 rails g rspec:install
274 rails generate integrateion_test static_pages
after this i have write down this code in static_pages_soec,rb
require 'spec_helper'
describe "StaticPages" 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
after that run this command but getting error
jaskaran@jaskaran-Vostro-1550:~/rails_project$ bundle exec rspec spec/requests/static pages spec.rb
/home/jaskaran/.rvm/gems/ruby-2.1.0/gems/rspec-core-2.14.8/lib/rspec
/core/configuration.rb:896:in `load': cannot load such file -- /home/jaskaran/rails_project/pages (LoadError)
from /home/jaskaran/.rvm/gems/ruby-2.1.0/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:896:in `block in load_spec_files'
from /home/jaskaran/.rvm/gems/ruby-2.1.0/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:896:in `each'
from /home/jaskaran/.rvm/gems/ruby-2.1.0/gems/rspec-core-2.14.8/lib/rspec/core/configuration.rb:896:in `load_spec_files'
from /home/jaskaran/.rvm/gems/ruby-2.1.0/gems/rspec-core-2.14.8/lib/rspec/core/command_line.rb:22:in `run'
from /home/jaskaran/.rvm/gems/ruby-2.1.0/gems/rspec-core-2.14.8/lib/rspec/core/runner.rb:80:in `run'
from /home/jaskaran/.rvm/gems/ruby-2.1.0/gems/rspec-core-2.14.8/lib/rspec/core/runner.rb:17:in `block in autorun'
Looks like there is a typo in your code.
page.should have content('Sample App')
should be
page.should have_content('Sample App')
If you are ever in doubt with Mike Hartl's tutorial you can always check the complete version here
The command you're running is incorrect.
You made a file called static_pages_spec.rb
(at least I hope you did - your question is riddled with typos) but your command is looking for static pages spec.rb
Fix the command by adding the underscores.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.