Class: Sus::Receive::Times

Inherits:
Object
  • Object
show all
Defined in:
lib/sus/receive.rb

Overview

Represents a constraint on method call count.

Constant Summary collapse

AT_LEAST_ONCE =

A predicate that matches at least one call.

Be.new(:>=, 1)

Instance Method Summary collapse

Constructor Details

#initialize(condition = AT_LEAST_ONCE) ⇒ Times

Initialize a new Times constraint.



255
256
257
# File 'lib/sus/receive.rb', line 255

def initialize(condition = AT_LEAST_ONCE)
	@condition = condition
end

Instance Method Details

#call(assertions, subject) ⇒ Object

Evaluate this constraint against a call count.



268
269
270
271
272
# File 'lib/sus/receive.rb', line 268

def call(assertions, subject)
	assertions.nested(self) do |assertions|
		Expect.new(assertions, subject).to(@condition)
	end
end

Print a representation of this constraint.



261
262
263
# File 'lib/sus/receive.rb', line 261

def print(output)
	output.write("with call count ", @condition)
end