Module: RSpec::ChangeToNow::Matchers::DSL::Detect

Included in:
RSpec::ChangeToNow::Matchers::DSL
Defined in:
lib/rspec/change_to_now/matchers/dsl.rb

Instance Method Summary collapse

Instance Method Details

#detect(*expected, &block) ⇒ Object

If given a block, passes if the block returns a truthy value for any of the actual items or for the key-value pair is the actual item list is a hash. Without a block, it behaves identically to include. expected must be empty if a block is provided.

Examples:

expect([2]).to detect(&:even?)
expect({a: 2}).to detect { |k,v| v.even? }
expect([1]).to detect 1


30
31
32
# File 'lib/rspec/change_to_now/matchers/dsl.rb', line 30

def detect(*expected, &block)
  RSpec::ChangeToNow::Matchers::Detect.new(*expected, &block)
end