Class: SolidUseCase::RSpecMatchers::MatchFailure
- Inherits:
-
Object
- Object
- SolidUseCase::RSpecMatchers::MatchFailure
- Defined in:
- lib/solid_use_case/rspec_matchers.rb
Instance Method Summary collapse
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(expected_error_name) ⇒ MatchFailure
constructor
A new instance of MatchFailure.
- #matches?(result) ⇒ Boolean
Constructor Details
#initialize(expected_error_name) ⇒ MatchFailure
Returns a new instance of MatchFailure.
41 42 43 |
# File 'lib/solid_use_case/rspec_matchers.rb', line 41 def initialize(expected_error_name) @expected_error_name = expected_error_name end |
Instance Method Details
#failure_message ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/solid_use_case/rspec_matchers.rb', line 51 def if @is_failure "expected result to fail with :#{@expected_error_name} (failed with :#{@result.value.type} instead)" else "expected result to fail with :#{@expected_error_name} (result was successful instead)" end end |
#failure_message_when_negated ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/solid_use_case/rspec_matchers.rb', line 59 def if @is_failure "expected result to fail with an error not equal to :#{@expected_error_name}" else "expected result to fail with an error not equal to :#{@expected_error_name} (result was successful instead)" end end |
#matches?(result) ⇒ Boolean
45 46 47 48 49 |
# File 'lib/solid_use_case/rspec_matchers.rb', line 45 def matches?(result) @result = result @is_failure = @result.is_a?(Deterministic::Failure) @is_failure && @result.value.type == @expected_error_name end |