Class: GraphqlRails::RSpecControllerHelpers::SingleControllerSchemaBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql_rails/rspec_controller_helpers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller) ⇒ SingleControllerSchemaBuilder

Returns a new instance of SingleControllerSchemaBuilder.



84
85
86
# File 'lib/graphql_rails/rspec_controller_helpers.rb', line 84

def initialize(controller)
  @controller = controller
end

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



82
83
84
# File 'lib/graphql_rails/rspec_controller_helpers.rb', line 82

def controller
  @controller
end

Instance Method Details

#callObject



88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/graphql_rails/rspec_controller_helpers.rb', line 88

def call
  config = controller.controller_configuration
  action_by_name = config.action_by_name
  controller_path = controller.name.underscore.sub(/_controller\Z/, '')

  router = Router.draw do
    action_by_name.keys.each do |action_name|
      query("#{action_name}_test", to: "#{controller_path}##{action_name}", group: :graphql_rspec_helpers)
    end
  end

  router.graphql_schema(:graphql_rspec_helpers)
end