Class: RSpec::Matchers::BuiltIn::YieldWithArgs
- Inherits:
-
Object
- Object
- RSpec::Matchers::BuiltIn::YieldWithArgs
- Defined in:
- lib/rspec/matchers/built_in/yield.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
-
#initialize(*args) ⇒ YieldWithArgs
constructor
A new instance of YieldWithArgs.
- #matches?(block) ⇒ Boolean (also: #==)
Constructor Details
#initialize(*args) ⇒ YieldWithArgs
Returns a new instance of YieldWithArgs.
109 110 111 |
# File 'lib/rspec/matchers/built_in/yield.rb', line 109 def initialize(*args) @expected = args end |
Instance Method Details
#description ⇒ Object
128 129 130 131 132 |
# File 'lib/rspec/matchers/built_in/yield.rb', line 128 def description desc = "yield with args" desc << "(" + @expected.map { |e| e.inspect }.join(", ") + ")" unless @expected.empty? desc end |
#failure_message_for_should ⇒ Object
120 121 122 |
# File 'lib/rspec/matchers/built_in/yield.rb', line 120 def "expected given block to yield with arguments, but #{positive_failure_reason}" end |
#failure_message_for_should_not ⇒ Object
124 125 126 |
# File 'lib/rspec/matchers/built_in/yield.rb', line 124 def "expected given block not to yield with arguments, but #{negative_failure_reason}" end |
#matches?(block) ⇒ Boolean Also known as: ==
113 114 115 116 117 |
# File 'lib/rspec/matchers/built_in/yield.rb', line 113 def matches?(block) @probe = YieldProbe.probe(block) @actual = @probe.single_yield_args @probe.yielded_once?(:yield_with_args) && args_match? end |