Class: RSpec::GraphqlMatchers::HaveAFieldMatchers::WithDeprecationReason
- Inherits:
-
Object
- Object
- RSpec::GraphqlMatchers::HaveAFieldMatchers::WithDeprecationReason
- Defined in:
- lib/rspec/graphql_matchers/have_a_field_matchers/with_deprecation_reason.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(expected_reason) ⇒ WithDeprecationReason
constructor
A new instance of WithDeprecationReason.
- #matches?(actual_field) ⇒ Boolean
Constructor Details
#initialize(expected_reason) ⇒ WithDeprecationReason
Returns a new instance of WithDeprecationReason.
7 8 9 |
# File 'lib/rspec/graphql_matchers/have_a_field_matchers/with_deprecation_reason.rb', line 7 def initialize(expected_reason) @expected_reason = expected_reason end |
Instance Method Details
#description ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/rspec/graphql_matchers/have_a_field_matchers/with_deprecation_reason.rb', line 26 def description if @expected_reason.nil? 'with a deprecation reason' else "with deprecation reason `#{@expected_reason}`" end end |
#failure_message ⇒ Object
21 22 23 24 |
# File 'lib/rspec/graphql_matchers/have_a_field_matchers/with_deprecation_reason.rb', line 21 def = "#{description}, but it was " + (@actual_reason.nil? ? 'not deprecated' : "`#{@actual_reason}`") end |
#matches?(actual_field) ⇒ Boolean
11 12 13 14 15 16 17 18 19 |
# File 'lib/rspec/graphql_matchers/have_a_field_matchers/with_deprecation_reason.rb', line 11 def matches?(actual_field) @actual_reason = actual_field.deprecation_reason if @expected_reason.nil? !actual_field.deprecation_reason.nil? else actual_field.deprecation_reason == @expected_reason end end |