Class: ExampleExpectations::ArbitraryMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/vendor/plugins/rspec/spec/spec/expectations/handler_spec.rb

Direct Known Subclasses

PositiveOnlyMatcher

Instance Method Summary collapse

Constructor Details

#initialize(*args, &block) ⇒ ArbitraryMatcher

Returns a new instance of ArbitraryMatcher.



6
7
8
9
10
11
12
# File 'lib/vendor/plugins/rspec/spec/spec/expectations/handler_spec.rb', line 6

def initialize(*args, &block)
  if args.last.is_a? Hash
    @expected = args.last[:expected]
  end
  @expected = block.call if block
  @block = block
end

Instance Method Details

#failure_messageObject



24
25
26
# File 'lib/vendor/plugins/rspec/spec/spec/expectations/handler_spec.rb', line 24

def failure_message
  "expected #{@expected}, got #{@target}"
end

#matches?(target) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/vendor/plugins/rspec/spec/spec/expectations/handler_spec.rb', line 14

def matches?(target)
  @target = target
  return @expected == target
end

#negative_failure_messageObject



28
29
30
# File 'lib/vendor/plugins/rspec/spec/spec/expectations/handler_spec.rb', line 28

def negative_failure_message
  "expected not #{@expected}, got #{@target}"
end

#with(new_value) ⇒ Object



19
20
21
22
# File 'lib/vendor/plugins/rspec/spec/spec/expectations/handler_spec.rb', line 19

def with(new_value)
  @expected = new_value
  self
end