Class: CabezaDeTermo::JsonSpec::DefaultExpectationBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/cabeza-de-termo/json-spec/expectations-library/default-expectations/default-expectation-builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(expectations_mapping, json_expression_type) ⇒ DefaultExpectationBuilder

Returns a new instance of DefaultExpectationBuilder.



6
7
8
9
# File 'lib/cabeza-de-termo/json-spec/expectations-library/default-expectations/default-expectation-builder.rb', line 6

def initialize(expectations_mapping, json_expression_type)
	@expectations_mapping = expectations_mapping
	@json_expression_type = json_expression_type
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/cabeza-de-termo/json-spec/expectations-library/default-expectations/default-expectation-builder.rb', line 19

def method_missing(method_name, *args)
	expectations_mapping.add_expectation(
		json_expression_type, 
		Message.new(method_name.to_sym, *args)
	)

	self
end

Instance Method Details

#expectations_mappingObject



11
12
13
# File 'lib/cabeza-de-termo/json-spec/expectations-library/default-expectations/default-expectation-builder.rb', line 11

def expectations_mapping
	@expectations_mapping
end

#json_expression_typeObject



15
16
17
# File 'lib/cabeza-de-termo/json-spec/expectations-library/default-expectations/default-expectation-builder.rb', line 15

def json_expression_type
	@json_expression_type
end