Skip to content

Commit

Permalink
add a new context to test if GIT_COMMIT_SHA exists
Browse files Browse the repository at this point in the history
  • Loading branch information
ihab4real committed Nov 12, 2024
1 parent 2d18704 commit 309d712
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions spec/system/pages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@
GitCommitSha.reset_current_sha
end

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

before do
# stub this method since we need to control what the sha actually is
allow(GitCommitSha).to receive(:retrieve_sha_from_git) { sha }
ENV["GIT_COMMIT_SHA"] = sha
end

after do
ENV.delete("GIT_COMMIT_SHA")
end

it_behaves_like "Git Commit SHA"
Expand All @@ -39,4 +42,16 @@

it_behaves_like "Git Commit SHA"
end

context "when falling back to git command" do
let(:sha) { "94d92356828a56db25fccff9d50f41c525eead5x" }
let(:expected_text) { "94d9235" }

before do
# stub this method since we need to control what the sha actually is
allow(GitCommitSha).to receive(:retrieve_sha_from_git) { sha }
end

it_behaves_like "Git Commit SHA"
end
end

0 comments on commit 309d712

Please sign in to comment.