Module: Inertia::RSpec::RequestHelpers
- Defined in:
- lib/inertia/rspec.rb
Instance Method Summary collapse
-
#get(inertia: nil, headers: {}) ⇒ Object
Performs a GET request with optional Inertia partial reload headers.
Instance Method Details
#get(inertia: nil, headers: {}) ⇒ Object
Performs a GET request with optional Inertia partial reload headers.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/inertia/rspec.rb', line 97 def get(*, inertia: nil, headers: {}, **) if inertia inertia = {} unless inertia.is_a?(Hash) if inertia.except(:only, :except).any? raise ArgumentError, "Unknown :inertia option. Supported values are :only and :except" end headers = headers.merge({ "X-Inertia" => "true", "X-Inertia-Partial-Component" => self.inertia&.component || double(:== => true) }) if only = inertia[:only] headers["X-Inertia-Partial-Data"] = Array(only).join(",") elsif except = inertia[:except] headers["X-Inertia-Partial-Except"] = Array(except).join(",") end end super(*, headers:, **) end |