Class: RSpec::GraphQLResponse::Validators::ValidationBase

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/graphql_response/validators/validation_base.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.failure_message(type, msg) ⇒ Object



6
7
8
9
# File 'lib/rspec/graphql_response/validators/validation_base.rb', line 6

def failure_message(type, msg)
  @messages ||= {}
  @messages[type] = msg
end

.validate(&validate_method) ⇒ Object



11
12
13
# File 'lib/rspec/graphql_response/validators/validation_base.rb', line 11

def validate(&validate_method)
  @validate_method = validate_method
end

.validate_negated(&validate_negated_method) ⇒ Object



15
16
17
# File 'lib/rspec/graphql_response/validators/validation_base.rb', line 15

def validate_negated(&validate_negated_method)
  @validate_negated_method = validate_negated_method
end

Instance Method Details

#failure_message(type) ⇒ Object



34
35
36
# File 'lib/rspec/graphql_response/validators/validation_base.rb', line 34

def failure_message(type)
  self.class.instance_variable_get(:@messages)[type]
end

#validate(response, *args) ⇒ Object



20
21
22
23
24
25
# File 'lib/rspec/graphql_response/validators/validation_base.rb', line 20

def validate(response, *args)
  validate_method = self.class.instance_variable_get(:@validate_method)

  runner = ValidationRunner.new(self)
  runner.instance_exec(response, *args, &validate_method)
end

#validate_negated(response, *args) ⇒ Object



27
28
29
30
31
32
# File 'lib/rspec/graphql_response/validators/validation_base.rb', line 27

def validate_negated(response, *args)
  validate_negated_method = self.class.instance_variable_get(:@validate_negated_method)

  runner = ValidationRunner.new(self)
  runner.instance_exec(response, *args, &validate_negated_method)
end