Skip to content
This repository has been archived by the owner on Sep 29, 2021. It is now read-only.

Commit

Permalink
Add confirmation and failure tests for git name
Browse files Browse the repository at this point in the history
  • Loading branch information
mfinelli committed Nov 4, 2015
1 parent 62f464f commit 8c446af
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions spec/gembuild_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,29 @@
end
end

describe '.fetch_git_global_name' do
context 'with successful call to git and confirmation' do
it 'should return the value from git' do
expect(Gembuild).to receive(:`).with('git config --global user.name').and_return('A Name')
allow($CHILD_STATUS).to receive(:success?).and_return(true)
expect(STDOUT).to receive(:puts).with('Detected "A Name", is this correct? (y/n)')
allow(Gembuild).to receive(:gets) { "y\n" }
expect(Gembuild.fetch_git_global_name).to eql('A Name')
end
end

context 'with a failure call to git' do
it 'should return the value entered' do
expect(Gembuild).to receive(:`).with('git config --global user.name').and_return('Fail Name')
allow($CHILD_STATUS).to receive(:success?).and_return(false)
expect(STDOUT).to receive(:puts).with('Could not detect name from git configuration.')
expect(STDOUT).to receive(:puts).with('Please enter desired name: ')
allow(Gembuild).to receive(:gets) { "A Name After Failure\n" }
expect(Gembuild.fetch_git_global_name).to eql('A Name After Failure')
end
end
end

describe '.configure' do
context 'with normal behavior' do
it 'should respond to configure' do
Expand Down

0 comments on commit 8c446af

Please sign in to comment.