テスト上の理由から、私は最近、DSL ではなくクラス形式を使用するように、いくつかの RSpec マッチャーを移動しました。この形式の場合に連鎖動作を簡単に取得する方法はありますか。
例えば
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
どうもありがとう