Module: Inertia::RSpec::TestHelpers

Defined in:
lib/inertia/rspec.rb

Instance Method Summary collapse

Instance Method Details

#inertiaTestResponse?

Returns the Inertia response from the last request.

Examples:

get "/users/1"
expect(inertia.component).to eq("Users/Show")
expect(inertia.props[:user]).to include(name: "John")

Returns:

  • (TestResponse, nil)

    the wrapped Inertia response, or nil if the last request was not an Inertia response



66
67
68
69
70
71
# File 'lib/inertia/rspec.rb', line 66

def inertia
  inertia_response = Fiber.current.instance_variable_get(:@__inertia_current_response)
  return unless inertia_response

  TestResponse.new(inertia_response)
end