Skip to content

Commit 1f57542

Browse files
committed
Account for FastlaneCore::Helper:is_ci? usage in tests
1 parent a748da6 commit 1f57542

File tree

2 files changed

+6
-26
lines changed

2 files changed

+6
-26
lines changed

spec/file_reference_spec.rb

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,17 @@
6969

7070
describe '#source_contents' do
7171
it 'gets the contents from the secrets repo' do
72-
set_circle_env(false) do
73-
allow(File).to receive(:read).with(subject.secrets_repository_file_path).and_return('source contents')
74-
expect(subject.source_contents).to eq('source contents')
75-
end
72+
allow(FastlaneCore::Helper).to receive(:is_ci?).and_return(false)
73+
allow(File).to receive(:read).with(subject.secrets_repository_file_path).and_return('source contents')
74+
expect(subject.source_contents).to eq('source contents')
7675
end
7776
end
7877

7978
describe '#source_contents on ci' do
8079
it 'gets the contents from the secrets repo' do
81-
set_circle_env(true) do
82-
allow(File).to receive(:read).with(subject.secrets_repository_file_path).and_return('source contents')
83-
expect(subject.source_contents).to eq(nil)
84-
end
80+
allow(FastlaneCore::Helper).to receive(:is_ci?).and_return(true)
81+
allow(File).to receive(:read).with(subject.secrets_repository_file_path).and_return('source contents')
82+
expect(subject.source_contents).to eq(nil)
8583
end
8684
end
8785

spec/spec_helper.rb

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,6 @@ module SpecHelper
2525
config.filter_run_when_matching :focus
2626
end
2727

28-
def set_circle_env(define_ci)
29-
is_ci = ENV.key?('CIRCLECI')
30-
orig_circle_ci = ENV['CIRCLECI']
31-
if define_ci
32-
ENV['CIRCLECI'] = 'true'
33-
else
34-
ENV.delete 'CIRCLECI'
35-
end
36-
37-
yield
38-
ensure
39-
if is_ci
40-
ENV['CIRCLECI'] = orig_circle_ci
41-
else
42-
ENV.delete 'CIRCLECI'
43-
end
44-
end
45-
4628
# Allows Action.sh to be executed even when running in a test environment (where Fastlane's code disables it by default)
4729
#
4830
def allow_fastlane_action_sh

0 commit comments

Comments
 (0)