Skip to content

Commit ccd6dd9

Browse files
committed
Update tests
1 parent a12b1cd commit ccd6dd9

File tree

3 files changed

+52
-9
lines changed

3 files changed

+52
-9
lines changed

Gemfile.lock

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
fastlane-plugin-wpmreleasetoolkit (0.8.2)
4+
fastlane-plugin-wpmreleasetoolkit (0.9.2)
55
activesupport (~> 4)
66
chroma (= 0.2.0)
77
diffy (~> 3.3)
@@ -97,7 +97,7 @@ GEM
9797
xcpretty (~> 0.3.0)
9898
xcpretty-travis-formatter (>= 0.0.3)
9999
gh_inspector (1.1.3)
100-
git (1.6.0)
100+
git (1.7.0)
101101
rchardet (~> 1.8)
102102
google-api-client (0.23.9)
103103
addressable (~> 2.5, >= 2.5.1)
@@ -148,13 +148,13 @@ GEM
148148
multipart-post (2.0.0)
149149
nanaimo (0.2.6)
150150
naturally (2.2.0)
151-
nokogiri (1.10.8)
151+
nokogiri (1.10.9)
152152
mini_portile2 (~> 2.4.0)
153-
octokit (4.16.0)
153+
octokit (4.18.0)
154154
faraday (>= 0.9)
155155
sawyer (~> 0.8.0, >= 0.5.3)
156-
oj (3.10.2)
157-
optimist (3.0.0)
156+
oj (3.10.6)
157+
optimist (3.0.1)
158158
options (2.3.2)
159159
os (1.0.1)
160160
parallel (1.17.0)
@@ -234,7 +234,7 @@ GEM
234234
tty-screen (0.7.0)
235235
tty-spinner (0.9.1)
236236
tty-cursor (~> 0.7)
237-
tzinfo (1.2.6)
237+
tzinfo (1.2.7)
238238
thread_safe (~> 0.1)
239239
uber (0.1.0)
240240
unf (0.1.4)

spec/file_reference_spec.rb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,19 @@
5454

5555
describe '#source_contents' do
5656
it 'gets the contents from the secrets repo' do
57-
allow(File).to receive(:read).with(subject.secrets_repository_file_path).and_return('source contents')
58-
expect(subject.source_contents).to eq('source contents')
57+
set_circle_env(false) do
58+
allow(File).to receive(:read).with(subject.secrets_repository_file_path).and_return('source contents')
59+
expect(subject.source_contents).to eq('source contents')
60+
end
61+
end
62+
end
63+
64+
describe '#source_contents_on_ci' do
65+
it 'gets the contents from the secrets repo' do
66+
set_circle_env(true) do
67+
allow(File).to receive(:read).with(subject.secrets_repository_file_path).and_return('source contents')
68+
expect(subject.source_contents).to eq(nil)
69+
end
5970
end
6071
end
6172

spec/spec_helper.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,35 @@ module SpecHelper
2525
RSpec.configure do |config|
2626
config.filter_run_when_matching :focus
2727
end
28+
29+
def set_circle_env(define_ci)
30+
is_ci = ENV.key?('CIRCLECI')
31+
orig_circle_ci = ENV['CIRCLECI']
32+
if (define_ci)
33+
ENV['CIRCLECI'] = 'CircleCI'
34+
else
35+
ENV.delete 'CIRCLECI'
36+
end
37+
38+
yield
39+
ensure
40+
if (is_ci)
41+
ENV['CIRCLECI'] = orig_circle_ci
42+
else
43+
ENV.delete 'CIRCLECI'
44+
end
45+
end
46+
47+
def define_circle_env()
48+
is_ci = ENV.key?('CIRCLECI')
49+
orig_circle_ci = ENV['CIRCLECI']
50+
51+
52+
yield
53+
ensure
54+
if (is_ci)
55+
ENV['CIRCLECI'] = orig_circle_ci
56+
else
57+
ENV.delete 'CIRCLECI'
58+
end
59+
end

0 commit comments

Comments
 (0)