0
Я пытаюсь объединить два пользовательских шаблона, используя ожидания блоков.RSpec .and and block expect
Это пример:
expect{puts "test"}.to matcher1.and matcher2
И вот matchers:
RSpec::Matchers.define :matcher1 do |resource|
supports_block_expectations
match do |actual|
puts "before matcher1"
actual[]
puts "after matcher1"
true
end
end
RSpec::Matchers.define :matcher2 do
supports_block_expectations
match do |actual|
puts "before matcher2"
actual[]
puts "after matcher2"
true
end
end
И выход я получаю:
before matcher2
before matcher1
test
after matcher1
after matcher2
В то время как я ожидал :
before matcher2
test
after matcher2
before matcher1
test
after matcher1
Почему мой пророк называется только один раз, и почему странное гнездование? Есть ли способ достичь того, чего я хочу, не повторяя блок?