Module: Graphiti::Rails::RakeHelpers
- Extended by:
- TestHelpers
- Defined in:
- lib/graphiti/rails/rake_helpers.rb
Overview
Rake's namespace takes a block, and a block does not open a new definee,
so helpers defined inside one are defined on Object and turn up in every
request spec in the host app. They live here to stay off that namespace.
Class Method Summary collapse
- .make_request(path, debug = false) ⇒ Object
-
.session ⇒ Object
::Rails throughout, because bare Rails resolves to Graphiti::Rails here.
- .setup_rails! ⇒ Object
Methods included from TestHelpers
handle_request_exceptions, handle_request_exceptions?
Class Method Details
.make_request(path, debug = false) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/graphiti/rails/rake_helpers.rb', line 24 def make_request(path, debug = false) if path.split("/").length == 2 path = "#{ApplicationResource.endpoint_namespace}#{path}" end path << if path.include?("?") "&cache=bust" else "?cache=bust" end path = "#{path}&debug=true" if debug handle_request_exceptions do headers = {Authorization: ENV["AUTHORIZATION_HEADER"]}.compact session.get(path.to_s, headers: headers) end JSON.parse(session.response.body) end |
.session ⇒ Object
::Rails throughout, because bare Rails resolves to Graphiti::Rails here.
14 15 16 |
# File 'lib/graphiti/rails/rake_helpers.rb', line 14 def session @session ||= ActionDispatch::Integration::Session.new(::Rails.application) end |
.setup_rails! ⇒ Object
18 19 20 21 22 |
# File 'lib/graphiti/rails/rake_helpers.rb', line 18 def setup_rails! ::Rails.application.eager_load! ::Rails.application.config.cache_classes = true ::Rails.application.config.action_controller.perform_caching = false end |