Class: Interactify::RSpecMatchers::ContractMatcher
- Inherits:
-
Object
- Object
- Interactify::RSpecMatchers::ContractMatcher
- Defined in:
- lib/interactify/rspec_matchers/matchers.rb
Instance Attribute Summary collapse
-
#actual ⇒ Object
readonly
Returns the value of attribute actual.
-
#actual_values ⇒ Object
readonly
Returns the value of attribute actual_values.
-
#expected_values ⇒ Object
readonly
Returns the value of attribute expected_values.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #extra ⇒ Object
- #failure_message ⇒ Object
-
#initialize(actual, expected_values, actual_values, type) ⇒ ContractMatcher
constructor
A new instance of ContractMatcher.
- #missing ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(actual, expected_values, actual_values, type) ⇒ ContractMatcher
Returns a new instance of ContractMatcher.
10 11 12 13 14 15 |
# File 'lib/interactify/rspec_matchers/matchers.rb', line 10 def initialize(actual, expected_values, actual_values, type) @actual = actual @expected_values = expected_values @actual_values = actual_values @type = type end |
Instance Attribute Details
#actual ⇒ Object (readonly)
Returns the value of attribute actual.
8 9 10 |
# File 'lib/interactify/rspec_matchers/matchers.rb', line 8 def actual @actual end |
#actual_values ⇒ Object (readonly)
Returns the value of attribute actual_values.
8 9 10 |
# File 'lib/interactify/rspec_matchers/matchers.rb', line 8 def actual_values @actual_values end |
#expected_values ⇒ Object (readonly)
Returns the value of attribute expected_values.
8 9 10 |
# File 'lib/interactify/rspec_matchers/matchers.rb', line 8 def expected_values @expected_values end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
8 9 10 |
# File 'lib/interactify/rspec_matchers/matchers.rb', line 8 def type @type end |
Instance Method Details
#extra ⇒ Object
32 33 34 |
# File 'lib/interactify/rspec_matchers/matchers.rb', line 32 def extra actual_values - expected_values end |
#failure_message ⇒ Object
17 18 19 20 21 22 |
# File 'lib/interactify/rspec_matchers/matchers.rb', line 17 def = "expected #{actual} to #{type} #{expected_values.inspect}" += "\n\tmissing: #{missing}" if missing.any? += "\n\textra: #{extra}" if extra.any? end |
#missing ⇒ Object
28 29 30 |
# File 'lib/interactify/rspec_matchers/matchers.rb', line 28 def missing expected_values - actual_values end |
#valid? ⇒ Boolean
24 25 26 |
# File 'lib/interactify/rspec_matchers/matchers.rb', line 24 def valid? missing.empty? && extra.empty? end |