Class: Quickdraw::Expectation

Inherits:
Object
  • Object
show all
Defined in:
lib/quickdraw/expectation.rb

Instance Method Summary collapse

Constructor Details

#initialize(context, value = Quickdraw::Null, &block) ⇒ Expectation

Returns a new instance of Expectation.



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/quickdraw/expectation.rb', line 4

def initialize(context, value = Quickdraw::Null, &block)
	if block && Quickdraw::Null != value
		raise Quickdraw::ArgumentError.new(
			"You must only provide a value or a block to `expect`."
		)
	end

	@context = context
	@value = value
	@block = block
	@made_expectations = false
end

Instance Method Details

#failure!Object



22
23
24
25
# File 'lib/quickdraw/expectation.rb', line 22

def failure!(&)
	@context.failure!(&)
	@made_expectations = true
end

#resolveObject



27
28
29
30
31
# File 'lib/quickdraw/expectation.rb', line 27

def resolve
	if !@made_expectations
		failure! { "You didn't make any expectations." }
	end
end

#success!Object



17
18
19
20
# File 'lib/quickdraw/expectation.rb', line 17

def success!
	@context.success!
	@made_expectations = true
end