forked from shakacode/react_on_rails
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update #uncommitted_changes? to handle missing Git
- Fix for GitUtils.uncommitted_changes? throwing an error when called in an environment that does not have git installed - Add tests for GitUtils.uncommitted_changes? scenariors - Fixes shakacode#888
- Loading branch information
1 parent
51a4630
commit 62f6975
Showing
3 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "spec_helper" | ||
|
||
module ReactOnRails | ||
RSpec.describe GitUtils do | ||
describe ".uncommitted_changes?" do | ||
context "With uncommited git changes" do | ||
subject { "M file/path" } | ||
let(:message_handler) { instance_double("MessageHandler") } | ||
|
||
before do | ||
allow(described_class).to receive(:`).with("git status --porcelain").and_return(subject) | ||
expect(message_handler).to receive(:add_error) | ||
.with("You have uncommitted code. Please commit or stash your changes before continuing") | ||
end | ||
|
||
it "returns true" do | ||
expect(described_class.uncommitted_changes?(message_handler)).to eq(true) | ||
end | ||
end | ||
|
||
context "With clean git status" do | ||
subject { "" } | ||
let(:message_handler) { instance_double("MessageHandler") } | ||
|
||
before do | ||
allow(described_class).to receive(:`).with("git status --porcelain").and_return(subject) | ||
expect(message_handler).not_to receive(:add_error) | ||
end | ||
|
||
it "returns false" do | ||
expect(described_class.uncommitted_changes?(message_handler)).to eq(false) | ||
end | ||
end | ||
|
||
context "With git status failure" do | ||
subject { nil } | ||
let(:message_handler) { instance_double("MessageHandler") } | ||
|
||
before do | ||
allow(described_class).to receive(:`).with("git status --porcelain").and_return(subject) | ||
expect(message_handler).to receive(:add_error) | ||
.with("You have uncommitted code. Please commit or stash your changes before continuing") | ||
end | ||
|
||
it "returns true" do | ||
expect(described_class.uncommitted_changes?(message_handler)).to eq(true) | ||
end | ||
end | ||
end | ||
end | ||
end |