2011-09-09 4 views
4

나는 오이와 카피 바라와 레일 3.0.7 프로젝트를 실행 그리고 난 플래시 경우 확인하는 단계 정의가 [: 오류가] 존재 : 내 오이 테스트를 실행하면Cucumber-Capybara로 플래시 변수가없는 것을 어떻게 선언합니까?

Then /^I should be able to see the main page properly$/ do 
    current_path.should == "/" 
    flash[:error].should == nil 
end 

, 내가 얻을를 오류

And I should be able to see the main page properly # features/step_definitions/user_auth_steps.rb:17 
    undefined method `flash' for nil:NilClass (NoMethodError) 
    ./features/step_definitions/user_auth_steps.rb:19:in `/^I should be able to see the main page properly$/' 
    features/user_auth.feature:10:in `And I should be able to see the main page properly' 

가변 어설 션을 처리하는 올바른 방법입니까? 나는 세션 [: 무언가]를 사용한다면 동일한 유형의 오류가 발생한다는 것을 알았다.

답변

2

페이지에서 실제로 무엇이 보이는지 확인해야합니다. 이 경우 :

page.should_not have_css('.flash') 
0

(모든 종류의) 설정 flash 메시지가 없음을 주장하기 위해, 당신은 할 수 있습니다 :

assert_predicate flash, :empty? 

특정의 더 flash 메시지가 없음을 주장하기 위해 유형 세트 (이 예에서는 :error)를 사용하면 다음을 수행 할 수 있습니다.

assert_predicate flash[:error], :nil? 
관련 문제