Class: Surrogate::RSpec::TimesPredicate

Inherits:
Object
  • Object
show all
Defined in:
lib/surrogate/rspec/times_predicate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expected_times_invoked = 0, comparer = :<) ⇒ TimesPredicate

Returns a new instance of TimesPredicate.



5
6
7
8
# File 'lib/surrogate/rspec/times_predicate.rb', line 5

def initialize(expected_times_invoked=0, comparer=:<)
  self.expected_times_invoked = expected_times_invoked
  self.comparer = comparer
end

Instance Attribute Details

#comparerObject

Returns the value of attribute comparer.



4
5
6
# File 'lib/surrogate/rspec/times_predicate.rb', line 4

def comparer
  @comparer
end

#expected_times_invokedObject

Returns the value of attribute expected_times_invoked.



4
5
6
# File 'lib/surrogate/rspec/times_predicate.rb', line 4

def expected_times_invoked
  @expected_times_invoked
end

Instance Method Details

#default?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/surrogate/rspec/times_predicate.rb', line 14

def default?
  expected_times_invoked == 0 && comparer == :<
end

#matches?(invocations) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/surrogate/rspec/times_predicate.rb', line 10

def matches?(invocations)
  expected_times_invoked.send comparer, invocations.size
end