bundle exec rspec spec / requests / static_pages_spec.rb

时间:2014-05-31 20:06:47

标签: ruby-on-rails ruby rspec

在跟随Michael Hartl的RonR教程时,我正试图让我的主页通过我的书面测试。不幸的是,我无法弄清楚为什么我失败了?任何帮助将不胜感激..

规格/请求/ static_pages_spec.rb

require spec helper
require 'minitest/autorun'

describe "Static pages" do
  describe "Home page" do

    it "should have the content 'Sample App'" do
      visit '/static_pages/home'
      expect(page).to have_content('Sample App')

    end
  end
end

应用程序/视图/ static_pages / home.html.erb

<h1>Sample App</h1>
<p> This is the home page for the 
<a href="http://railstutorial.org/">Ruby on rails Tutorial</a>
sample application.
</p>

所以我跑..

$bundle exec rspec spec/requests/static_pages_spec.rb

结果是......

Failures:

  1) Static pages Home page should have the content 'Sample App'
     ←[31mFailure/Error:←[0m ←[31mvisit '/static_pages/home' # Run the generator again with the --webrat flag if you want to use webrat m
ethods/matchers←[0m
     ←[31mNoMethodError←[0m:
       ←[31mundefined method `visit' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x5ba9688>←[0m
←[36m     # ./spec/requests/static_pages_spec.rb:9:in `block (3 levels) in <top (required)>'←[0m

Finished in 0.002 seconds
←[31m1 example, 1 failure←[0m

Failed examples:

←[31mrspec ./spec/requests/static_pages_spec.rb:8←[0m ←[36m# Static pages Home page should have the content 'Sample App'←[0m

0 个答案:

没有答案