File tree Expand file tree Collapse file tree 4 files changed +22
-13
lines changed Expand file tree Collapse file tree 4 files changed +22
-13
lines changed Original file line number Diff line number Diff line change 7070 end
7171
7272 context 'with deep merge configured as the default' do
73- before {
74- InertiaRails . configure { |config | config . deep_merge_shared_data = true }
75- }
76- after {
77- InertiaRails . configure { |config | config . deep_merge_shared_data = false }
78- }
73+ with_inertia_config deep_merge_shared_data : true
74+
7975 describe 'deep merging by default' do
8076 let ( :props ) { { nested : { goals : 100 , assists : 200 } } }
8177 before { get merge_shared_path , headers : { 'X-Inertia' => true } }
Original file line number Diff line number Diff line change 33
44RSpec . describe 'inertia ssr' , type : :request do
55 context 'ssr is enabled' do
6- before do
7- InertiaRails . configure do |config |
8- config . ssr_enabled = true
9- config . ssr_url = 'ssr-url'
10- config . version = '1.0'
11- end
12- end
6+ with_inertia_config ssr_enabled : true , ssr_url : 'ssr-url' , version : '1.0'
137
148 context 'with a successful ssr response' do
159 before do
Original file line number Diff line number Diff line change 77
88 config . filter_run_when_matching :focus
99
10+ config . order = :random
11+
1012 config . expect_with :rspec do |c |
1113 c . syntax = :expect
1214 end
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
33module HelperModule
4+ def self . included ( base )
5+ base . extend ( ClassMethods )
6+ end
7+
48 def with_forgery_protection
59 orig = ActionController ::Base . allow_forgery_protection
610 begin
@@ -20,4 +24,17 @@ def with_env(**env)
2024 ENV . replace ( orig )
2125 end
2226 end
27+
28+ module ClassMethods
29+ def with_inertia_config ( **props )
30+ around do |example |
31+ config = InertiaRails . configuration
32+ orig_options = config . send ( :options ) . dup
33+ config . merge! ( InertiaRails ::Configuration . new ( **props ) )
34+ example . run
35+ ensure
36+ config . instance_variable_set ( :@options , orig_options )
37+ end
38+ end
39+ end
2340end
You can’t perform that action at this time.
0 commit comments