Class: RSpec::LogMatcher::Matcher
- Inherits:
-
Object
- Object
- RSpec::LogMatcher::Matcher
- Defined in:
- lib/rspec/log_matcher/matcher.rb
Constant Summary collapse
- LOG_PATH =
ENV.fetch('LOG_PATH', 'log/test.log')
Instance Attribute Summary collapse
-
#expected_logs ⇒ Object
readonly
Returns the value of attribute expected_logs.
-
#initial_log_file_position ⇒ Object
readonly
Returns the value of attribute initial_log_file_position.
Instance Method Summary collapse
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(expected_logs, initial_log_file_position) ⇒ Matcher
constructor
A new instance of Matcher.
- #matches?(subject) ⇒ Boolean
- #supports_block_expectations? ⇒ Boolean
Constructor Details
#initialize(expected_logs, initial_log_file_position) ⇒ Matcher
Returns a new instance of Matcher.
10 11 12 13 |
# File 'lib/rspec/log_matcher/matcher.rb', line 10 def initialize(expected_logs, initial_log_file_position) @expected_logs = expected_logs @initial_log_file_position = initial_log_file_position || 0 end |
Instance Attribute Details
#expected_logs ⇒ Object (readonly)
Returns the value of attribute expected_logs.
8 9 10 |
# File 'lib/rspec/log_matcher/matcher.rb', line 8 def expected_logs @expected_logs end |
#initial_log_file_position ⇒ Object (readonly)
Returns the value of attribute initial_log_file_position.
8 9 10 |
# File 'lib/rspec/log_matcher/matcher.rb', line 8 def initial_log_file_position @initial_log_file_position end |
Instance Method Details
#failure_message ⇒ Object
28 29 30 |
# File 'lib/rspec/log_matcher/matcher.rb', line 28 def "Expected subject to have logged `#{expected_logs}' in:\n\t#{logs}" end |
#failure_message_when_negated ⇒ Object
32 33 34 |
# File 'lib/rspec/log_matcher/matcher.rb', line 32 def "Expected subject not to have logged `#{expected_logs}' in:\n\t#{logs}" end |
#matches?(subject) ⇒ Boolean
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rspec/log_matcher/matcher.rb', line 15 def matches?(subject) prepare_matcher(subject) case expected_logs when Regexp logs.match?(expected_logs) when Proc logs.include?(expected_logs.call) when String logs.include?(expected_logs) end end |
#supports_block_expectations? ⇒ Boolean
36 37 38 |
# File 'lib/rspec/log_matcher/matcher.rb', line 36 def supports_block_expectations? true end |