Class: RSpec::PathMatchers::Options::Content
- Defined in:
- lib/rspec/path_matchers/options/content.rb
Overview
content:
Class Method Summary collapse
- .fetch_actual(path, _failures) ⇒ Object
- .key ⇒ Object
- .literal_failure_message(actual, expected) ⇒ Object
-
.literal_match?(actual, expected) ⇒ Boolean
Override to provide custom matching logic for regexp literals.
-
.matcher_failure_message(actual, expected) ⇒ Object
Handles failures when a matcher is used (e.g., content: include('...')).
- .valid_expected_types ⇒ Object
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) |
.key ⇒ Object
10 |
# File 'lib/rspec/path_matchers/options/content.rb', line 10 def self.key = :content |
.literal_failure_message(actual, expected) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rspec/path_matchers/options/content.rb', line 25 def self.(actual, expected) verb = expected.is_a?(Regexp) ? 'match' : 'be' actual_summary = if actual.length > 100 verb == 'match' ? 'did not' : 'was not' else "was #{actual.inspect}" end "expected content to #{verb} #{expected.inspect}, but it #{actual_summary}" end |
.literal_match?(actual, expected) ⇒ Boolean
Override to provide custom matching logic for regexp literals
15 16 17 |
# File 'lib/rspec/path_matchers/options/content.rb', line 15 def self.literal_match?(actual, expected) expected.is_a?(Regexp) ? expected.match?(actual) : super end |
.matcher_failure_message(actual, expected) ⇒ Object
Handles failures when a matcher is used (e.g., content: include('...'))
20 21 22 23 |
# File 'lib/rspec/path_matchers/options/content.rb', line 20 def self.(actual, expected) actual_summary = actual.length > 100 ? 'did not' : "was #{actual.inspect}" "expected content to #{expected.description}, but it #{actual_summary}" end |
.valid_expected_types ⇒ Object
12 |
# File 'lib/rspec/path_matchers/options/content.rb', line 12 def self.valid_expected_types = [String, Regexp] |