Class: RSpec::GraphqlMatchers::BeOfType
- Inherits:
-
BaseMatcher
- Object
- BaseMatcher
- RSpec::GraphqlMatchers::BeOfType
- Defined in:
- lib/rspec/graphql_matchers/be_of_type.rb
Direct Known Subclasses
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.
10 11 12 |
# File 'lib/rspec/graphql_matchers/be_of_type.rb', line 10 def initialize(expected) @expected = expected end |
Instance Attribute Details
#expected ⇒ Object (readonly)
Returns the value of attribute expected.
8 9 10 |
# File 'lib/rspec/graphql_matchers/be_of_type.rb', line 8 def expected @expected end |
#sample ⇒ Object (readonly)
Returns the value of attribute sample.
8 9 10 |
# File 'lib/rspec/graphql_matchers/be_of_type.rb', line 8 def sample @sample end |
Instance Method Details
#description ⇒ Object
24 25 26 |
# File 'lib/rspec/graphql_matchers/be_of_type.rb', line 24 def description "be of type '#{expected}'" end |
#failure_message ⇒ Object
19 20 21 22 |
# File 'lib/rspec/graphql_matchers/be_of_type.rb', line 19 def "expected field '#{member_name(sample)}' to be of type '#{expected}', " \ "but it was '#{type_name(sample.type)}'" end |
#matches?(actual_sample) ⇒ Boolean
14 15 16 17 |
# File 'lib/rspec/graphql_matchers/be_of_type.rb', line 14 def matches?(actual_sample) @sample = to_graphql(actual_sample) sample.respond_to?(:type) && types_match?(sample.type, @expected) end |