Class: RSpec::PathMatchers::Options::Content

Inherits:
Base
  • Object
show all
Defined in:
lib/rspec/path_matchers/options/content.rb

Overview

content: <expected>

Class Method Summary collapse

Methods inherited from Base

description, match, validate_expected

Class Method Details

.fetch_actual(path, _failures) ⇒ Object



11
# File 'lib/rspec/path_matchers/options/content.rb', line 11

def self.fetch_actual(path, _failures) = File.read(path)

.keyObject



10
# File 'lib/rspec/path_matchers/options/content.rb', line 10

def self.key = :content

.literal_failure_message(actual, expected) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/rspec/path_matchers/options/content.rb', line 20

def self.literal_failure_message(actual, expected)
  if expected.is_a?(Regexp)
    "expected content to match #{expected.inspect}, but got #{actual.inspect}"
  else
    super
  end
end

.literal_match?(actual, expected) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'lib/rspec/path_matchers/options/content.rb', line 14

def self.literal_match?(actual, expected)
  return expected.match?(actual) if expected.is_a?(Regexp)

  super
end

.valid_expected_typesObject



12
# File 'lib/rspec/path_matchers/options/content.rb', line 12

def self.valid_expected_types = [String, Regexp]