forked from shakacode/react-webpack-rails-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpages_spec.rb
More file actions
57 lines (42 loc) · 1.35 KB
/
pages_spec.rb
File metadata and controls
57 lines (42 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# frozen_string_literal: true
require "rails_helper"
shared_examples "Git Commit SHA" do
before { visit root_path }
it "displays the current git commit" do
el = find("#git-commit-sha")
expect(el.text).to eq expected_text
end
end
describe "Git Commit SHA" do
before do
# sha gets cached as an instance variable, so need to start fresh
GitCommitSha.reset_current_sha
end
context "when GIT_COMMIT_SHA env var exists" do
let(:sha) { "94d92356828a56db25fccff9d50f41c525eead5z" }
let(:expected_text) { "94d9235" }
before do
ENV["GIT_COMMIT_SHA"] = sha
end
after do
ENV.delete("GIT_COMMIT_SHA")
end
it_behaves_like "Git Commit SHA"
end
context "when .source_version file exists" do
let(:sha) { "94d92356828a56db25fccff9d50f41c525eead5y" }
let(:expected_text) { "94d9235" }
before { `cd #{Rails.root} && echo #{sha} > .source_version` }
after { `cd #{Rails.root} && rm .source_version` }
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