forked from shakacode/react-webpack-rails-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpages_spec.rb
34 lines (30 loc) · 1.03 KB
/
pages_spec.rb
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
require "rails_helper"
shared_examples "Git Commit SHA" do
background { visit root_path }
it "displays the current git commit" do
el = find("#git-commit-sha")
expect(el.text).to eq expected_text
end
end
feature "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 .source_version file does not exist" do
let(:sha) { "94d92356828a56db25fccff9d50f41c525eead5x" }
let(:expected_text) { "5eead5x" }
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
context "when .source_version file exists" do
let(:sha) { "94d92356828a56db25fccff9d50f41c525eead5y" }
let(:expected_text) { "5eead5y" }
before { `cd #{Rails.root} && echo #{sha} > .source_version` }
after { `cd #{Rails.root} && rm .source_version` }
it_behaves_like "Git Commit SHA"
end
end