Class: IncludeMatcher
- Defined in:
- lib/extensions/mspec/mspec/matchers/include.rb
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(*expected) ⇒ IncludeMatcher
constructor
A new instance of IncludeMatcher.
- #matches?(actual) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(*expected) ⇒ IncludeMatcher
Returns a new instance of IncludeMatcher.
2 3 4 |
# File 'lib/extensions/mspec/mspec/matchers/include.rb', line 2 def initialize(*expected) @expected = expected end |
Instance Method Details
#failure_message ⇒ Object
17 18 19 |
# File 'lib/extensions/mspec/mspec/matchers/include.rb', line 17 def ["Expected #{@actual.inspect}", "to include #{@element.inspect}"] end |
#matches?(actual) ⇒ Boolean
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/extensions/mspec/mspec/matchers/include.rb', line 6 def matches?(actual) @actual = actual @expected.each do |e| @element = e unless @actual.include?(e) return false end end return true end |
#negative_failure_message ⇒ Object
21 22 23 |
# File 'lib/extensions/mspec/mspec/matchers/include.rb', line 21 def ["Expected #{@actual.inspect}", "not to include #{@element.inspect}"] end |