Class: RSpec::GraphqlMatchers::BeOfType
- Inherits:
-
Object
- Object
- RSpec::GraphqlMatchers::BeOfType
- Defined in:
- lib/rspec/graphql_matchers/be_of_type.rb
Instance Attribute Summary collapse
-
#expected ⇒ Object
readonly
Returns the value of attribute expected.
-
#sample ⇒ Object
readonly
Returns the value of attribute sample.
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(expected) ⇒ BeOfType
constructor
A new instance of BeOfType.
- #matches?(actual_sample) ⇒ Boolean
Constructor Details
#initialize(expected) ⇒ BeOfType
Returns a new instance of BeOfType.
6 7 8 |
# File 'lib/rspec/graphql_matchers/be_of_type.rb', line 6 def initialize(expected) @expected = expected end |
Instance Attribute Details
#expected ⇒ Object (readonly)
Returns the value of attribute expected.
4 5 6 |
# File 'lib/rspec/graphql_matchers/be_of_type.rb', line 4 def expected @expected end |
#sample ⇒ Object (readonly)
Returns the value of attribute sample.
4 5 6 |
# File 'lib/rspec/graphql_matchers/be_of_type.rb', line 4 def sample @sample end |
Instance Method Details
#description ⇒ Object
20 21 22 |
# File 'lib/rspec/graphql_matchers/be_of_type.rb', line 20 def description "be of type '#{expected}'" end |
#failure_message ⇒ Object
15 16 17 18 |
# File 'lib/rspec/graphql_matchers/be_of_type.rb', line 15 def "expected field '#{field_name(sample)}' to be of type '#{expected}', " \ "but it was '#{sample.type}'" end |
#matches?(actual_sample) ⇒ Boolean
10 11 12 13 |
# File 'lib/rspec/graphql_matchers/be_of_type.rb', line 10 def matches?(actual_sample) @sample = actual_sample sample.type.to_s == @expected.to_s end |