Class: Sus::RespondTo::WithOptions

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

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ WithOptions

Returns a new instance of WithOptions.



36
37
38
# File 'lib/sus/respond_to.rb', line 36

def initialize(options)
	@options = options
end

Instance Method Details

#call(assertions, subject) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/sus/respond_to.rb', line 44

def call(assertions, subject)
	options = {}
	@options.each{|name| options[name] = nil}
	
	subject.each do |type, name|
		options[name] = type					
	end
	
	assertions.nested(self) do |assertions|
		options.each do |name, type|
			assertions.assert(type != nil, "option #{name}: is required")
		end
	end
end


40
41
42
# File 'lib/sus/respond_to.rb', line 40

def print(output)
	output.write("with options ", :variable, @options.inspect)
end