Class: Salestation::RSpec::GliaInputValidationErrorMatcher
- Inherits:
-
Object
- Object
- Salestation::RSpec::GliaInputValidationErrorMatcher
- Includes:
- RSpec::Matchers::Composable
- Defined in:
- lib/salestation/rspec/glia_input_validation_error_matcher.rb
Instance Attribute Summary collapse
-
#actual ⇒ Object
readonly
Returns the value of attribute actual.
-
#expected ⇒ Object
readonly
Returns the value of attribute expected.
-
#failure_message ⇒ Object
readonly
Returns the value of attribute failure_message.
Class Method Summary collapse
Instance Method Summary collapse
- #exactly ⇒ Object
-
#initialize ⇒ GliaInputValidationErrorMatcher
constructor
A new instance of GliaInputValidationErrorMatcher.
- #matches?(actual) ⇒ Boolean
- #on(*nested_fields) ⇒ Object
- #with_message(*messages) ⇒ Object
- #with_type(*types) ⇒ Object
Constructor Details
#initialize ⇒ GliaInputValidationErrorMatcher
Returns a new instance of GliaInputValidationErrorMatcher.
12 13 14 15 16 17 |
# File 'lib/salestation/rspec/glia_input_validation_error_matcher.rb', line 12 def initialize @fields = [] @field_error_types = {} @field_error_messages = {} @expect_exact_match = false end |
Instance Attribute Details
#actual ⇒ Object (readonly)
Returns the value of attribute actual.
10 11 12 |
# File 'lib/salestation/rspec/glia_input_validation_error_matcher.rb', line 10 def actual @actual end |
#expected ⇒ Object (readonly)
Returns the value of attribute expected.
10 11 12 |
# File 'lib/salestation/rspec/glia_input_validation_error_matcher.rb', line 10 def expected @expected end |
#failure_message ⇒ Object (readonly)
Returns the value of attribute failure_message.
10 11 12 |
# File 'lib/salestation/rspec/glia_input_validation_error_matcher.rb', line 10 def @failure_message end |
Class Method Details
.path_list_to_trie(paths) ⇒ Object
111 112 113 114 115 |
# File 'lib/salestation/rspec/glia_input_validation_error_matcher.rb', line 111 def path_list_to_trie(paths) paths.reduce({}) do |acc, path| deep_merge(acc, path_to_trie(*path)) end end |
Instance Method Details
#exactly ⇒ Object
24 25 26 27 |
# File 'lib/salestation/rspec/glia_input_validation_error_matcher.rb', line 24 def exactly @expect_exact_match = true self end |
#matches?(actual) ⇒ Boolean
39 40 41 42 43 44 45 46 |
# File 'lib/salestation/rspec/glia_input_validation_error_matcher.rb', line 39 def matches?(actual) check_exact_match(actual, self.class.path_list_to_trie(@fields)) && @fields.all? do |field| check_field_exists(actual, *field) && check_field_error_types(field, actual) && (field, actual) end end |
#on(*nested_fields) ⇒ Object
19 20 21 22 |
# File 'lib/salestation/rspec/glia_input_validation_error_matcher.rb', line 19 def on(*nested_fields) @fields << nested_fields self end |
#with_message(*messages) ⇒ Object
34 35 36 37 |
# File 'lib/salestation/rspec/glia_input_validation_error_matcher.rb', line 34 def (*) @field_error_messages[field_to_key(@fields.last)] = self end |
#with_type(*types) ⇒ Object
29 30 31 32 |
# File 'lib/salestation/rspec/glia_input_validation_error_matcher.rb', line 29 def with_type(*types) @field_error_types[field_to_key(@fields.last)] = types self end |