Skip to content

Commit 30d7555

Browse files
committed
Set keyword argument defaults in the renderer method signature because that pattern will make adding options easier in the future by not requiring shotgun surgery on tests that invoke the renderer directly
1 parent e124497 commit 30d7555

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lib/inertia_rails/renderer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module InertiaRails
66
class Renderer
77
attr_reader :component, :view_data
88

9-
def initialize(component, controller, request, response, render_method, props:, view_data:, deep_merge:)
9+
def initialize(component, controller, request, response, render_method, props: nil, view_data: nil, deep_merge: nil)
1010
@component = component.is_a?(TrueClass) ? "#{controller.controller_path}/#{controller.action_name}" : component
1111
@controller = controller
1212
@request = request

spec/inertia/rendering_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
let(:controller) { double('Controller', inertia_view_assigns: {})}
55

66
context 'first load' do
7-
let(:page) { InertiaRails::Renderer.new('TestComponent', controller, request, response, '', props: nil, view_data: nil, deep_merge: nil).send(:page) }
7+
let(:page) { InertiaRails::Renderer.new('TestComponent', controller, request, response, '').send(:page) }
88

99
context 'with props' do
10-
let(:page) { InertiaRails::Renderer.new('TestComponent', controller, request, response, '', props: {name: 'Brandon', sport: 'hockey'}, view_data: nil, deep_merge: nil).send(:page) }
10+
let(:page) { InertiaRails::Renderer.new('TestComponent', controller, request, response, '', props: {name: 'Brandon', sport: 'hockey'}).send(:page) }
1111
before { get props_path }
1212

1313
it { is_expected.to include inertia_div(page) }
@@ -39,7 +39,7 @@
3939
end
4040

4141
context 'subsequent requests' do
42-
let(:page) { InertiaRails::Renderer.new('TestComponent', controller, request, response, '', props: {name: 'Brandon', sport: 'hockey'}, view_data: nil, deep_merge: nil).send(:page) }
42+
let(:page) { InertiaRails::Renderer.new('TestComponent', controller, request, response, '', props: {name: 'Brandon', sport: 'hockey'}).send(:page) }
4343
let(:headers) { {'X-Inertia' => true} }
4444

4545
before { get props_path, headers: headers }
@@ -64,7 +64,7 @@
6464

6565
context 'partial rendering' do
6666
let (:page) {
67-
InertiaRails::Renderer.new('TestComponent', controller, request, response, '', props: { sport: 'hockey'}, view_data: nil, deep_merge: nil).send(:page)
67+
InertiaRails::Renderer.new('TestComponent', controller, request, response, '', props: { sport: 'hockey'}).send(:page)
6868
}
6969
let(:headers) {{
7070
'X-Inertia' => true,
@@ -94,7 +94,7 @@
9494
context 'lazy prop rendering' do
9595
context 'on first load' do
9696
let (:page) {
97-
InertiaRails::Renderer.new('TestComponent', controller, request, response, '', props: { name: 'Brian'}, view_data: nil, deep_merge: nil).send(:page)
97+
InertiaRails::Renderer.new('TestComponent', controller, request, response, '', props: { name: 'Brian'}).send(:page)
9898
}
9999
before { get lazy_props_path }
100100

@@ -103,7 +103,7 @@
103103

104104
context 'with a partial reload' do
105105
let (:page) {
106-
InertiaRails::Renderer.new('TestComponent', controller, request, response, '', props: { sport: 'basketball', level: 'worse than he believes', grit: 'intense'}, view_data: nil, deep_merge: nil).send(:page)
106+
InertiaRails::Renderer.new('TestComponent', controller, request, response, '', props: { sport: 'basketball', level: 'worse than he believes', grit: 'intense'}).send(:page)
107107
}
108108
let(:headers) {{
109109
'X-Inertia' => true,

0 commit comments

Comments
 (0)