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.



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

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

Instance Method Details

#call(assertions, subject) ⇒ Object

Evaluate this constraint against a call count.



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

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

Print a representation of this constraint.



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

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