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 70
70
end
71
71
72
72
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
+
79
75
describe 'deep merging by default' do
80
76
let ( :props ) { { nested : { goals : 100 , assists : 200 } } }
81
77
before { get merge_shared_path , headers : { 'X-Inertia' => true } }
Original file line number Diff line number Diff line change 3
3
4
4
RSpec . describe 'inertia ssr' , type : :request do
5
5
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'
13
7
14
8
context 'with a successful ssr response' do
15
9
before do
Original file line number Diff line number Diff line change 7
7
8
8
config . filter_run_when_matching :focus
9
9
10
+ config . order = :random
11
+
10
12
config . expect_with :rspec do |c |
11
13
c . syntax = :expect
12
14
end
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
3
module HelperModule
4
+ def self . included ( base )
5
+ base . extend ( ClassMethods )
6
+ end
7
+
4
8
def with_forgery_protection
5
9
orig = ActionController ::Base . allow_forgery_protection
6
10
begin
@@ -20,4 +24,17 @@ def with_env(**env)
20
24
ENV . replace ( orig )
21
25
end
22
26
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
23
40
end
You can’t perform that action at this time.
0 commit comments