2012-04-21 2 views
1

레일을 사용하고 있습니다. 다음 명령을 사용하여 루비 스크립트를 실행합니다. 그리고 오류가 발생합니다. 뭐가 문제 야? "page.should have_content ('Demo App')"을 제거하면 제대로 작동합니다!정의되지 않은 지역 변수 또는 메소드`page '

bundle exec rspec spec/requests/test_pages_spec.rb 

Failures: 

1) Test pages Home page should have the content 'Demo App' 
Failure/Error: page.should have_content('Demo App') 
NameError: 
    undefined local variable or method `page' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0xa60d538> 
# ./spec/requests/test_pages_spec.rb:9:in `block (3 levels) in <top (required)>' 

Finished in 0.27788 seconds 
1 example, 1 failure 

Failed examples: 

rspec ./spec/requests/test_pages_spec.rb:7 # Test pages Home page should have the content 'Demo App' 

test_pages_spec.rb은 다음과 같다 :이 문제를 해결 한

require 'spec_helper' 

describe "Test pages" do 

describe "Home page" do 

    it "should have the content 'Demo App'" do 
    visit '/test_pages/home' 
    page.should have_content('Demo App') 
    end 
end 
end 

답변

3

. 나는 webrat과 capybara를 둘 다 사용하면 적절한 결과를 볼 수 없습니다. 그래서 gemfile 'webrat'을 Gemfile에서 제거하고 번들 업데이트을 입력하고 다음 명령을 사용하면 문제가 해결됩니다!

bundle exec rspec spec/requests/test_pages_spec.rb 
관련 문제