File tree Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,6 @@ def call(*args)
1717 def initialize ( argv , env = ENV )
1818 @argv = argv
1919 @env = env
20-
21- self . class . env . clear
2220 end
2321
2422 def call
@@ -32,7 +30,7 @@ def populate_env_vars
3230 return if early_envs . empty?
3331
3432 ( env . keys - early_envs ) . each do |key |
35- next if env_excluded ?( key )
33+ next if ignore_var ?( key )
3634
3735 self . class . env [ key ] = env [ key ]
3836 end
@@ -56,7 +54,7 @@ def early_envs
5654 @early_envs ||= env [ "DIP_EARLY_ENVS" ] . to_s . split ( "," )
5755 end
5856
59- def env_excluded ?( key )
57+ def ignore_var ?( key )
6058 key . start_with? ( "DIP_" , "_" )
6159 end
6260 end
Original file line number Diff line number Diff line change 88 end
99
1010 context "when env vars in argv" do
11- specify do
11+ it "parses them and stores in class var" do
1212 expect ( described_class . call ( %w( FOO=foo BAR=bar run rspec ) ) ) . to eq %w( run rspec )
1313 expect ( described_class . env ) . to include ( "FOO" => "foo" , "BAR" => "bar" )
1414 end
15+
16+ context "and call multiple times" do
17+ it "doesn't reset previous vars" do
18+ expect ( described_class . call ( %w( FOO=foo BAR=bar run rspec ) ) ) . to eq %w( run rspec )
19+ expect ( described_class . call ( %w( run rspec ) ) ) . to eq %w( run rspec )
20+ expect ( described_class . env ) . to include ( "FOO" => "foo" , "BAR" => "bar" )
21+ end
22+ end
1523 end
1624
1725 context "when early_envs is present" do
Original file line number Diff line number Diff line change 4343
4444 config . before do
4545 Dip . reset!
46+ Dip ::RunVars . env . clear
4647 end
4748
4849 Kernel . srand config . seed
You can’t perform that action at this time.
0 commit comments