Module: InertiaHanami::Testing::RequestHelpers
- Defined in:
- lib/inertia_hanami/testing/rspec.rb
Overview
Request-spec helpers for reading the current Inertia response and
re-issuing partial-reload requests. Mixed into RSpec example groups
below; assumes the host group already provides last_response,
last_request, and get (e.g. via include Rack::Test::Methods).
Instance Method Summary collapse
- #inertia ⇒ Object
- #inertia_load_deferred_props(group = nil) ⇒ Object
- #inertia_reload_except(*props) ⇒ Object
- #inertia_reload_only(*props) ⇒ Object
Instance Method Details
#inertia ⇒ Object
220 221 222 |
# File 'lib/inertia_hanami/testing/rspec.rb', line 220 def inertia TestResponse.new(last_response) end |
#inertia_load_deferred_props(group = nil) ⇒ Object
232 233 234 235 236 237 238 |
# File 'lib/inertia_hanami/testing/rspec.rb', line 232 def inertia_load_deferred_props(group = nil) deferred = inertia.deferred_props keys = group ? Array(deferred[group.to_sym]) : deferred.values.flatten return if keys.empty? inertia_reload_only(*keys) end |
#inertia_reload_except(*props) ⇒ Object
228 229 230 |
# File 'lib/inertia_hanami/testing/rspec.rb', line 228 def inertia_reload_except(*props) get last_request.fullpath, {}, partial_reload_headers.merge("HTTP_X_INERTIA_PARTIAL_EXCEPT" => props.join(",")) end |
#inertia_reload_only(*props) ⇒ Object
224 225 226 |
# File 'lib/inertia_hanami/testing/rspec.rb', line 224 def inertia_reload_only(*props) get last_request.fullpath, {}, partial_reload_headers.merge("HTTP_X_INERTIA_PARTIAL_DATA" => props.join(",")) end |