Class: RSpec::Matchers::BuiltIn::Include

Inherits:
BaseMatcher show all
Defined in:
lib/rspec/matchers/built_in/include.rb

Constant Summary

Constant Summary

Constants inherited from BaseMatcher

BaseMatcher::UNDEFINED

Instance Attribute Summary

Attributes inherited from BaseMatcher

#actual, #expected, #rescued_exception

Instance Method Summary (collapse)

Methods inherited from BaseMatcher

#failure_message_for_should, #failure_message_for_should_not, #match_unless_raises, #supports_block_expectations?

Methods included from MatchAliases

#==, #===

Methods included from Pretty

#_pretty_print, #expected_to_sentence, #name, #name_to_sentence, #split_words, #to_sentence, #to_word, #underscore

Constructor Details

- (Include) initialize(*expected)

A new instance of Include

5
6
7
# File 'lib/rspec/matchers/built_in/include.rb', line 5
def initialize(*expected)
  @expected = expected
end

Instance Method Details

- (Object) description

19
20
21
# File 'lib/rspec/matchers/built_in/include.rb', line 19
def description
  "include#{to_sentence expected}"
end

- (Boolean) diffable?

Returns:

  • (Boolean)
23
24
25
26
27
# File 'lib/rspec/matchers/built_in/include.rb', line 23
def diffable?
  # Matchers do not diff well, since diff uses their inspect
  # output, which includes their instance variables and such.
  @expected.none? { |e| RSpec::Matchers.is_a_matcher?(e) }
end

- (Boolean) does_not_match?(actual)

Returns:

  • (Boolean)
14
15
16
17
# File 'lib/rspec/matchers/built_in/include.rb', line 14
def does_not_match?(actual)
  @actual = actual
  perform_match(:none?, :any?, @actual, @expected)
end

- (Boolean) matches?(actual)

Returns:

  • (Boolean)
9
10
11
12
# File 'lib/rspec/matchers/built_in/include.rb', line 9
def matches?(actual)
  @actual = actual
  perform_match(:all?, :all?, @actual, @expected)
end