diff --git a/lib/inertia_rails/rspec.rb b/lib/inertia_rails/rspec.rb index a2da420..2f274a8 100644 --- a/lib/inertia_rails/rspec.rb +++ b/lib/inertia_rails/rspec.rb @@ -25,9 +25,16 @@ def wrap_render(render_method) protected def set_values(params) - @view_data = params[:locals].except(:page) - @props = params[:locals][:page][:props] - @component = params[:locals][:page][:component] + if params[:locals].present? + @view_data = params[:locals].except(:page) + @props = params[:locals][:page][:props] + @component = params[:locals][:page][:component] + else + # Sequential Inertia request + @view_data = {} + @props = params[:json][:props] + @component = params[:json][:component] + end end end diff --git a/spec/inertia/rspec_helper_spec.rb b/spec/inertia/rspec_helper_spec.rb index 4356e73..12a6fb3 100644 --- a/spec/inertia/rspec_helper_spec.rb +++ b/spec/inertia/rspec_helper_spec.rb @@ -34,6 +34,22 @@ def puts(thing) end end + context 'with props during sequential request' do + before { get props_path, headers: {'X-Inertia': true} } + + it 'has props' do + expect_inertia.to have_exact_props({name: 'Brandon', sport: 'hockey'}) + end + + it 'includes props' do + expect_inertia.to include_props({sport: 'hockey'}) + end + + it 'can retrieve props' do + expect(inertia.props[:name]).to eq 'Brandon' + end + end + context 'with view data' do before { get view_data_path }