2012-03-28 3 views
3

배열에 어떤 값이 포함되어 있지 않은지 확인하기 위해 RSpec 테스트를 어떻게 기술 할 수 있습니까? 이런 식으로 뭔가 : 내 상태를 다시 작성할 수 있습니다은 포함하지 않아야 함

tags.should include("one") 
tags.should not include("two") 

:

tags.include?("two").should be_false 

하지만 더 아름다운 해결책을 찾고 있어요.

답변

7

RSpec은 should_not이고 should입니다.

tags.should include("one") 
tags.should_not include("two") 

여기에 포함 일치의 일부 more examples. RSpec에 v3의

8

은 :

expect(my_string).to include "some value" 


expect(my_string).not_to include "some value" 
+0

이 지금 should''를 통해 구문을 선호된다. – theUtherSide

관련 문제