class ErgomentumRspec::Matchers::Yield::YieldAll

Public Class Methods

new(expected) click to toggle source
# File lib/ergomentum_rspec/matchers/yield/yield_all.rb, line 19
def initialize(expected)
  @expected = expected
end

Public Instance Methods

description() click to toggle source
# File lib/ergomentum_rspec/matchers/yield/yield_all.rb, line 58
def description
  "yields all"
end
failure_message() click to toggle source
# File lib/ergomentum_rspec/matchers/yield/yield_all.rb, line 50
def failure_message
  if @expected.respond_to?(:failure_message)
    "Failed for #{ActiveSupport::Inflector.ordinalize(@count)} yield with:\n#{@expected.failure_message}"
  else
    "Expecting #{@expected} got #{@last} for #{ActiveSupport::Inflector.ordinalize(@count)} yield"
  end
end
match(actual) click to toggle source
# File lib/ergomentum_rspec/matchers/yield/yield_all.rb, line 40
def match(actual)
  @count += 1
  @last = actual
  @result &&= if @expected.respond_to?(:matches?)
                @expected.matches?(actual)
              else
                values_match?(@expected, actual)
              end
end
matches?(*block) { |method(:match)| ... } click to toggle source
# File lib/ergomentum_rspec/matchers/yield/yield_all.rb, line 27
def matches?(*block)
  @count = 0
  @result = true
  if block_given?
    yield(method(:match))
  elsif block.first.is_a?(Proc)
    block.first.call(method(:match))
  else
    raise NoBlockGivenError
  end
  @result
end
supports_block_expectations?() click to toggle source
# File lib/ergomentum_rspec/matchers/yield/yield_all.rb, line 23
def supports_block_expectations?
  true
end