Class: Inertia::RSpec::TestResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/inertia/rspec.rb

Overview

Wraps an Inertia response for test assertions.

Examples:

Accessing response data

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

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ TestResponse

Returns a new instance of TestResponse.

Parameters:

  • data (Hash)

    the raw Inertia response data



14
15
16
# File 'lib/inertia/rspec.rb', line 14

def initialize(data)
  @data = data
end

Instance Method Details

#componentString

Returns the component name.

Returns:

  • (String)

    the Inertia component name



28
29
30
# File 'lib/inertia/rspec.rb', line 28

def component
  @data[:component]
end

#deferred_propsHash

Returns the deferred props configuration.

Returns:

  • (Hash)

    the deferred props, or an empty hash if none



35
36
37
# File 'lib/inertia/rspec.rb', line 35

def deferred_props
  @data[:deferredProps] || {}
end

#propsHash{Symbol => Object}

Returns the props with symbolized keys.

Returns:

  • (Hash{Symbol => Object})

    the props hash



21
22
23
# File 'lib/inertia/rspec.rb', line 21

def props
  sybmolize_keys(@data[:props])
end