rspec에서 값과 일치하는 방법이 있습니까? the documentation을 확인하면 anything
, an_instance_of
및 hash_including
과 같이 사용할 수있는 다른 matcher가있는 것처럼 보입니다.하지만 개체 속성의 값을 확인하는 것은 없습니다.rspec에서 인수의 속성 값과 일치
class DateParser
def parse_year(a_date)
puts a_date.year
end
end
그런 다음 나는이 같은 기대를 작성할 수 있습니다 : -
예 I이 인스턴스 방법이 있다고 가정 내가 parse_year
어떤 객체로 호출되는 것을 확인 some_matcher
원하는 무엇
dp = DateParser.new
expect(dp).to receive(:parse_year).with(some_matcher)
값이 2014 인 year
속성이 있습니다. rspec의 out-of-the-box 인수 matcher를 사용하여이 작업을 수행 할 수 있습니까? 아니면 사용자 지정 작업을 작성해야합니까?
"블록"형식의 출처는 어디입니까? 문서에서 찾을 수 없습니다 https://relishapp.com/rspec/rspec-mocks/v/3-2/docs/setting-constraints/matching-arguments – duleorlovic
@duleorlovic [인수를 확인하기 위해 블록 사용] (https : //relishapp.com/rspec/rspec-mocks/v/3-6/docs/configuring-responses/block-implementation#use-a-block-to-verify-arguments) – Stefan