class Hashema::RSpecMatchers::ConformToSchema
Public Class Methods
new(schema)
click to toggle source
# File lib/hashema/conform_to_schema.rb, line 9 def initialize(schema) @schema = schema @with_indifferent_access = false end
Public Instance Methods
description()
click to toggle source
# File lib/hashema/conform_to_schema.rb, line 41 def description "match schema\n#{@schema.inspect}" end
failure_message()
click to toggle source
# File lib/hashema/conform_to_schema.rb, line 24 def failure_message @validator.failure_message end
failure_message_for_should()
click to toggle source
# File lib/hashema/conform_to_schema.rb, line 28 def failure_message_for_should failure_message end
failure_message_for_should_not()
click to toggle source
# File lib/hashema/conform_to_schema.rb, line 37 def failure_message_for_should_not failure_message_when_negated end
failure_message_when_negated()
click to toggle source
# File lib/hashema/conform_to_schema.rb, line 32 def failure_message_when_negated # TODO: @actual is nil here. This probably doesn't work. "expected\n#{@actual.inspect}\nnot to match schema\n#{@schema.inspect}" end
matches?(actual)
click to toggle source
# File lib/hashema/conform_to_schema.rb, line 19 def matches?(actual) @validator = Hashema::Validator.new(actual, @schema, validator_options) @validator.valid? end
validator_options()
click to toggle source
# File lib/hashema/conform_to_schema.rb, line 45 def validator_options {indifferent_access: @with_indifferent_access} end
with_indifferent_access()
click to toggle source
# File lib/hashema/conform_to_schema.rb, line 14 def with_indifferent_access @with_indifferent_access = true self end