Class: Smartest::ContainExactlyMatcher
- Inherits:
-
Object
- Object
- Smartest::ContainExactlyMatcher
- Defined in:
- lib/smartest/matchers.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(expected_items, matcher_name:) ⇒ ContainExactlyMatcher
constructor
A new instance of ContainExactlyMatcher.
- #matches?(actual) ⇒ Boolean
- #negated_failure_message ⇒ Object
Constructor Details
#initialize(expected_items, matcher_name:) ⇒ ContainExactlyMatcher
Returns a new instance of ContainExactlyMatcher.
251 252 253 254 255 |
# File 'lib/smartest/matchers.rb', line 251 def initialize(expected_items, matcher_name:) @expected_items = expected_items @matcher_name = matcher_name reset_result end |
Instance Method Details
#description ⇒ Object
276 277 278 |
# File 'lib/smartest/matchers.rb', line 276 def description "#{@matcher_name} #{format_expected_items(@expected_items)}" end |
#failure_message ⇒ Object
266 267 268 269 270 |
# File 'lib/smartest/matchers.rb', line 266 def details = failure_details = "expected #{@actual.inspect} to #{@matcher_name} #{format_expected_items(@expected_items)}" details.empty? ? : "#{}; #{details.join('; ')}" end |
#matches?(actual) ⇒ Boolean
257 258 259 260 261 262 263 264 |
# File 'lib/smartest/matchers.rb', line 257 def matches?(actual) @actual = actual reset_result return false unless actual_items? match_items @missing_items.empty? && @extra_items.empty? end |
#negated_failure_message ⇒ Object
272 273 274 |
# File 'lib/smartest/matchers.rb', line 272 def "expected #{@actual.inspect} not to #{@matcher_name} #{format_expected_items(@expected_items)}" end |