Ruby on rails第5章教程失败

时间:2014-08-06 01:53:20

标签: ruby-on-rails ruby rspec

我正在编写第5章的教程,我得到了这个错误。 我已经尝试通过引用其他问题来修复它但仍然无法找到问题

这是我的失败

syahmies-MacBook-Air:sample_app syahmie$ bundle exec rspec spec/requests/static_pages_spec.rb
.F.F.FF..

Failures:

  1) Static pages Contact page
     Failure/Error: it { should have_title(full_title('Contact')) }
     NoMethodError:
       undefined method `full_title' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_4:0x007fe5f9609168>
     # ./spec/requests/static_pages_spec.rb:33:in `block (3 levels) in <top (required)>'

  2) Static pages Help page
     Failure/Error: it { should have_title(full_title('Help')) }
     NoMethodError:
       undefined method `full_title' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_2:0x007fe5f92bf7c8>
     # ./spec/requests/static_pages_spec.rb:19:in `block (3 levels) in <top (required)>'

  3) Static pages About page
     Failure/Error: it { should have_title(full_title('About Us')) }
     NoMethodError:
       undefined method `full_title' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_3:0x007fe5fc83b2d0>
     # ./spec/requests/static_pages_spec.rb:26:in `block (3 levels) in <top (required)>'

  4) Static pages Home page
     Failure/Error: it { should have_title(full_title('')) }
     NoMethodError:
       undefined method `full_title' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x007fe5fc90b138>
     # ./spec/requests/static_pages_spec.rb:11:in `block (3 levels) in <top (required)>'

Finished in 0.30171 seconds
9 examples, 4 failures

Failed examples:

rspec ./spec/requests/static_pages_spec.rb:33 # Static pages Contact page
rspec ./spec/requests/static_pages_spec.rb:19 # Static pages Help page
rspec ./spec/requests/static_pages_spec.rb:26 # Static pages About page
rspec ./spec/requests/static_pages_spec.rb:11 # Static pages Home page

Randomized with seed 35702

这是我的spec.rb文件

require 'spec_helper'

describe "Static pages" do

  subject { page }

  describe "Home page" do
    before { visit root_path }

    it { should have_content('Sample App') }
    it { should have_title(full_title('')) }
    it { should_not have_title('| Home') }
  end

  describe "Help page" do
    before { visit help_path }

    it { should have_content('Help') }
    it { should have_title(full_title('Help')) }
  end

  describe "About page" do
    before { visit about_path }

    it { should have_content('About') }
    it { should have_title(full_title('About Us')) }
  end

  describe "Contact page" do
    before { visit contact_path }

    it { should have_content('Contact') }
    it { should have_title(full_title('Contact')) }
  end

end

0 个答案:

没有答案