Class: RR::TimesCalledMatchers::TimesCalledMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/rr/times_called_matchers/times_called_matcher.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(times) ⇒ TimesCalledMatcher

Returns a new instance of TimesCalledMatcher.



16
17
18
# File 'lib/rr/times_called_matchers/times_called_matcher.rb', line 16

def initialize(times)
  @times = times
end

Instance Attribute Details

#timesObject (readonly)

Returns the value of attribute times.



14
15
16
# File 'lib/rr/times_called_matchers/times_called_matcher.rb', line 14

def times
  @times
end

Class Method Details

.create(value) ⇒ Object

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
# File 'lib/rr/times_called_matchers/times_called_matcher.rb', line 5

def create(value)
  return value if value.is_a?(TimesCalledMatcher)
  return IntegerMatcher.new(value) if value.is_a?(Integer)
  return RangeMatcher.new(value) if value.is_a?(Range )
  return ProcMatcher.new(value) if value.is_a?(Proc)
  raise ArgumentError, "There is no TimesCalledMatcher for #{value.inspect}."
end

Instance Method Details

#==(other) ⇒ Object



30
31
32
# File 'lib/rr/times_called_matchers/times_called_matcher.rb', line 30

def ==(other)
  self.class == other.class && self.times == other.times
end

#attempt?(times_called) ⇒ Boolean

Returns:

  • (Boolean)


23
24
# File 'lib/rr/times_called_matchers/times_called_matcher.rb', line 23

def attempt?(times_called)
end

#error_message(times_called) ⇒ Object



26
27
28
# File 'lib/rr/times_called_matchers/times_called_matcher.rb', line 26

def error_message(times_called)
  "Called #{times_called.inspect} #{pluralized_time(times_called)}.\n#{expected_message_part}"
end

#matches?(times_called) ⇒ Boolean

Returns:

  • (Boolean)


20
21
# File 'lib/rr/times_called_matchers/times_called_matcher.rb', line 20

def matches?(times_called)
end