Is it possible to chain two matchers and not have to yield the block given 
to expect twice?

The problem is yielding the block twice changes the test.

class FirstMatcher
  def matches?(block)
    @result = record_something do
      block.call # block called for first time
    end
    return true
  end

  def supports_block_expectations?
    true
  end

  def second_matcher?
    SecondMatcher.new
  end
end

class SecondMatcher
  def matches?(block)
    @result = record_something do
      block.call # block called for second time, can I get the original 
@result somehow?
    end
    return true
  end

  def supports_block_expectations?
    true
  end
end


# usage

expect { something }.to first_matcher.second_matcher

Many thanks, Kris.

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/427ee7aa-8cf2-4f20-964a-37da118be62f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to