Skip to content

Commit 309d712

Browse files
committed
add a new context to test if GIT_COMMIT_SHA exists
1 parent 2d18704 commit 309d712

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

spec/system/pages_spec.rb

+19-4
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@
1717
GitCommitSha.reset_current_sha
1818
end
1919

20-
context "when .source_version file does not exist" do
21-
let(:sha) { "94d92356828a56db25fccff9d50f41c525eead5x" }
20+
context "when GIT_COMMIT_SHA env var exists" do
21+
let(:sha) { "94d92356828a56db25fccff9d50f41c525eead5z" }
2222
let(:expected_text) { "94d9235" }
2323

2424
before do
25-
# stub this method since we need to control what the sha actually is
26-
allow(GitCommitSha).to receive(:retrieve_sha_from_git) { sha }
25+
ENV["GIT_COMMIT_SHA"] = sha
26+
end
27+
28+
after do
29+
ENV.delete("GIT_COMMIT_SHA")
2730
end
2831

2932
it_behaves_like "Git Commit SHA"
@@ -39,4 +42,16 @@
3942

4043
it_behaves_like "Git Commit SHA"
4144
end
45+
46+
context "when falling back to git command" do
47+
let(:sha) { "94d92356828a56db25fccff9d50f41c525eead5x" }
48+
let(:expected_text) { "94d9235" }
49+
50+
before do
51+
# stub this method since we need to control what the sha actually is
52+
allow(GitCommitSha).to receive(:retrieve_sha_from_git) { sha }
53+
end
54+
55+
it_behaves_like "Git Commit SHA"
56+
end
4257
end

0 commit comments

Comments
 (0)