Class: Operandi::RSpec::Matchers::HaveWarningOnMatcher
- Inherits:
-
Object
- Object
- Operandi::RSpec::Matchers::HaveWarningOnMatcher
- Defined in:
- lib/operandi/rspec/matchers/have_warning_on.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(key) ⇒ HaveWarningOnMatcher
constructor
A new instance of HaveWarningOnMatcher.
- #matches?(service) ⇒ Boolean
- #with_message(message) ⇒ Object
Constructor Details
#initialize(key) ⇒ HaveWarningOnMatcher
Returns a new instance of HaveWarningOnMatcher.
28 29 30 31 |
# File 'lib/operandi/rspec/matchers/have_warning_on.rb', line 28 def initialize(key) @key = key @expected_message = nil end |
Instance Method Details
#description ⇒ Object
64 65 66 67 68 |
# File 'lib/operandi/rspec/matchers/have_warning_on.rb', line 64 def description desc = "have warning on :#{@key}" desc += " with message #{@expected_message.inspect}" if @expected_message desc end |
#failure_message ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/operandi/rspec/matchers/have_warning_on.rb', line 47 def unless has_warning_key? return "expected service to have warning on :#{@key}, but warnings were: #{warnings_summary}" end return unless "" end |
#failure_message_when_negated ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/operandi/rspec/matchers/have_warning_on.rb', line 56 def if @expected_message "expected service not to have warning on :#{@key} with message #{@expected_message.inspect}" else "expected service not to have warning on :#{@key}" end end |
#matches?(service) ⇒ Boolean
38 39 40 41 42 43 44 45 |
# File 'lib/operandi/rspec/matchers/have_warning_on.rb', line 38 def matches?(service) @service = service return false unless has_warning_key? return false unless true end |
#with_message(message) ⇒ Object
33 34 35 36 |
# File 'lib/operandi/rspec/matchers/have_warning_on.rb', line 33 def () @expected_message = self end |