class RSpec::Matchers::BuiltIn::Include

@api private Provides the implementation for ‘include`. Not intended to be instantiated directly.

Attributes

Public Class Methods

@api private

# File rspec-expectations/lib/rspec/matchers/built_in/include.rb, line 15
def initialize(*expecteds)
  raise(ArgumentError, 'include() is not supported, please supply an argument') if expecteds.empty?
  @expecteds = expecteds
end

Public Instance Methods

@api private @return [String]

# File rspec-expectations/lib/rspec/matchers/built_in/include.rb, line 44
def description
  improve_hash_formatting("include#{readable_list_of(expecteds)}#{count_expectation_description}")
end

@api private @return [Boolean]

# File rspec-expectations/lib/rspec/matchers/built_in/include.rb, line 62
def diffable?
  !diff_would_wrongly_highlight_matched_item?
end

@api private @return [Boolean]

# File rspec-expectations/lib/rspec/matchers/built_in/include.rb, line 33
def does_not_match?(actual)
  check_actual?(actual) &&
    if check_expected_count?
      !expected_count_matches?(count_inclusions)
    else
      perform_match { |v| !v }
    end
end

@api private @return [Array, Hash]

# File rspec-expectations/lib/rspec/matchers/built_in/include.rb, line 68
def expected
  if expecteds.one? && Hash === expecteds.first
    expecteds.first
  else
    expecteds
  end
end

@api private @return [String]

# File rspec-expectations/lib/rspec/matchers/built_in/include.rb, line 50
def failure_message
  format_failure_message("to") { super }
end

@api private @return [String]

# File rspec-expectations/lib/rspec/matchers/built_in/include.rb, line 56
def failure_message_when_negated
  format_failure_message("not to") { super }
end

@api private @return [Boolean]

# File rspec-expectations/lib/rspec/matchers/built_in/include.rb, line 22
def matches?(actual)
  check_actual?(actual) &&
    if check_expected_count?
      expected_count_matches?(count_inclusions)
    else
      perform_match { |v| v }
    end
end