Class: CabezaDeTermo::JsonSpec::DefaultExpectationsMapping

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

Instance Method Summary collapse

Constructor Details

#initializeDefaultExpectationsMapping

Returns a new instance of DefaultExpectationsMapping.



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

def initialize()
	@default_expectations = {}

	drop_all_expectations
end

Instance Method Details

#add_expectation(json_expression_type, message) ⇒ Object



19
20
21
22
# File 'lib/cabeza-de-termo/json-spec/expectations-library/default-expectations/default-expectations-mapping.rb', line 19

def add_expectation(json_expression_type, message)
	@default_expectations[json_expression_type] << message
	self
end

#drop_all_expectationsObject



12
13
14
15
16
17
# File 'lib/cabeza-de-termo/json-spec/expectations-library/default-expectations/default-expectations-mapping.rb', line 12

def drop_all_expectations()
	drop_expectations_for(:objects)
	drop_expectations_for(:lists)
	drop_expectations_for(:fields)
	drop_expectations_for(:scalars)
end

#drop_expectations_for(json_expression_type) ⇒ Object



28
29
30
31
# File 'lib/cabeza-de-termo/json-spec/expectations-library/default-expectations/default-expectations-mapping.rb', line 28

def drop_expectations_for(json_expression_type)
	@default_expectations[json_expression_type] = []
	self
end

#expectations_for(json_expression_type) ⇒ Object



24
25
26
# File 'lib/cabeza-de-termo/json-spec/expectations-library/default-expectations/default-expectations-mapping.rb', line 24

def expectations_for(json_expression_type)
	@default_expectations[json_expression_type]
end

#for_every_expression_of(json_expression_type, &block) ⇒ Object



49
50
51
# File 'lib/cabeza-de-termo/json-spec/expectations-library/default-expectations/default-expectations-mapping.rb', line 49

def for_every_expression_of(json_expression_type, &block)
	CdT.bind_block_evaluation_to DefaultExpectationBuilder.new(self, json_expression_type), &block
end

#for_every_field(&block) ⇒ Object



41
42
43
# File 'lib/cabeza-de-termo/json-spec/expectations-library/default-expectations/default-expectations-mapping.rb', line 41

def for_every_field(&block)
	for_every_expression_of(:fields, &block)
end

#for_every_list(&block) ⇒ Object



37
38
39
# File 'lib/cabeza-de-termo/json-spec/expectations-library/default-expectations/default-expectations-mapping.rb', line 37

def for_every_list(&block)
	for_every_expression_of(:lists, &block)
end

#for_every_object(&block) ⇒ Object



33
34
35
# File 'lib/cabeza-de-termo/json-spec/expectations-library/default-expectations/default-expectations-mapping.rb', line 33

def for_every_object(&block)
	for_every_expression_of(:objects, &block)
end

#for_every_scalar(&block) ⇒ Object



45
46
47
# File 'lib/cabeza-de-termo/json-spec/expectations-library/default-expectations/default-expectations-mapping.rb', line 45

def for_every_scalar(&block)
	for_every_expression_of(:scalars, &block)
end