테스트 용으로 최근에 RSpec matcher의 일부를 DSL 대신 클래스 형식을 사용하도록 이동했습니다. 이 양식에있을 때 쉽게 체이닝 동작을 얻는 방법이 있습니까?Rspec 사용자 지정 Matcher를 연결
예.
class BeInZone
def initialize(expected)
@expected = expected
end
def matches?(target)
@target = target
@target.current_zone.eql?(Zone.new(@expected))
end
def failure_message
"expected #{@target.inspect} to be in Zone #{@expected}"
end
def negative_failure_message
"expected #{@target.inspect} not to be in Zone #{@expected}"
end
# chain methods here
end
많은 감사
연결할 수있는 연결 식 메서드 호출의 예를 들려 줄 수 있습니까? –