File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 10
10
Dotenv . instrumenter = ActiveSupport ::Notifications
11
11
12
12
# Watch all loaded env files with Spring
13
- if defined? ( Spring )
14
- ActiveSupport :: Notifications . subscribe ( "load.dotenv" ) do |* args |
13
+ ActiveSupport :: Notifications . subscribe ( "load.dotenv" ) do |* args |
14
+ if defined? ( Spring )
15
15
event = ActiveSupport ::Notifications ::Event . new ( *args )
16
16
Spring . watch event . payload [ :env ] . filename if Rails . application
17
17
end
Original file line number Diff line number Diff line change 34
34
Rails . env = "test"
35
35
Rails . application = nil
36
36
Rails . logger = nil
37
- Spring . watcher = Set . new # Responds to #add
38
37
39
38
begin
40
39
# Remove the singleton instance if it exists
76
75
end
77
76
78
77
it "watches other loaded files with Spring" do
78
+ stub_spring
79
79
application . initialize!
80
80
path = fixture_path ( "plain.env" )
81
81
Dotenv . load ( path )
93
93
subject { application . initialize! }
94
94
95
95
it "watches .env with Spring" do
96
+ stub_spring
96
97
subject
97
98
expect ( Spring . watcher ) . to include ( fixture_path ( ".env" ) . to_s )
98
99
end
204
205
expect ( Dotenv ::Rails . logger ) . to be ( logger )
205
206
end
206
207
end
208
+
209
+ def stub_spring
210
+ spring = Struct . new ( "Spring" , :watcher ) do
211
+ def watch ( path )
212
+ watcher . add path
213
+ end
214
+ end
215
+
216
+ stub_const "Spring" , spring . new ( Set . new )
217
+ end
207
218
end
You can’t perform that action at this time.
0 commit comments