class Shoulda::Matchers::Graphql::Fields::OfType
Attributes
type_name[RW]
Public Class Methods
new(field_name, type_name)
click to toggle source
Calls superclass method
Shoulda::Matchers::Graphql::Fields::FieldMatcher::new
# File lib/shoulda/matchers/graphql/fields/of_type.rb, line 8 def initialize(field_name, type_name) super(field_name) @type_name = type_name == :ID ? "ID" : type_name end
Public Instance Methods
description()
click to toggle source
Calls superclass method
Shoulda::Matchers::Graphql::Fields::FieldMatcher#description
# File lib/shoulda/matchers/graphql/fields/of_type.rb, line 18 def description super + ", of type #@type_name" end
failure_message()
click to toggle source
# File lib/shoulda/matchers/graphql/fields/of_type.rb, line 22 def failure_message "expected '#@field_name' to be of type #@type_name, but it was #{subject_return_type} instead" end
matches?(subject)
click to toggle source
Calls superclass method
Shoulda::Matchers::Graphql::Fields::FieldMatcher#matches?
# File lib/shoulda/matchers/graphql/fields/of_type.rb, line 13 def matches?(subject) super(subject) subject_return_type == type_name end
subject_return_type()
click to toggle source
# File lib/shoulda/matchers/graphql/fields/of_type.rb, line 26 def subject_return_type @subject.fields[@field_name].instance_variable_get("@return_type_expr") end