-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
95 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
require 'rspec/bash' | ||
|
||
describe 'n8l::git_check' do | ||
include Rspec::Bash | ||
|
||
let(:stubbed_env) { create_stubbed_env } | ||
subject(:func) { 'n8l::git_check' } | ||
|
||
context 'version good' do | ||
it 'prints version OK' do | ||
stubbed_env.stub_command('hash') # confirm git is in PATH | ||
stubbed_env.stub_command('git').outputs('git version 2.13.4') | ||
|
||
out, err, status = stubbed_env.execute_function( | ||
'scripts/newinstall.sh', | ||
func, | ||
) | ||
|
||
expect(status.exitstatus).to be 0 | ||
expect(out).to eq("Detected git version 2.13.4. OK.\n") | ||
expect(err).to eq('') | ||
end | ||
|
||
context 'batch mode' do | ||
it 'prints version OK' do | ||
stubbed_env.stub_command('hash') # confirm git is in PATH | ||
stubbed_env.stub_command('git').outputs('git version 2.13.4') | ||
|
||
out, err, status = stubbed_env.execute_function( | ||
'scripts/newinstall.sh', | ||
func, | ||
{ 'BATCH_FLAG' => 'true' }, | ||
) | ||
|
||
expect(status.exitstatus).to be 0 | ||
expect(out).to eq("Detected git version 2.13.4. OK.\n") | ||
expect(err).to eq('') | ||
end | ||
end | ||
end | ||
|
||
context 'version bad' do | ||
it 'prints warning' do | ||
stubbed_env.stub_command('hash') # confirm git is in PATH | ||
stubbed_env.stub_command('git').outputs('git version 1.8.2') | ||
stubbed_env.stub_command('read') | ||
|
||
out, err, status = stubbed_env.execute_function( | ||
'scripts/newinstall.sh', | ||
func, | ||
{ 'yn' => 'y' }, | ||
) | ||
expect(status.exitstatus).to be 0 | ||
expect(out).to match('Detected git version 1.8.2') | ||
expect(out).to match('Continuing without git') | ||
expect(err).to eq('') | ||
end | ||
|
||
it 'prints warning' do | ||
stubbed_env.stub_command('hash') # confirm git is in PATH | ||
stubbed_env.stub_command('git').outputs('git version 1.8.2') | ||
stubbed_env.stub_command('read') | ||
|
||
out, err, status = stubbed_env.execute_function( | ||
'scripts/newinstall.sh', | ||
func, | ||
{ 'yn' => 'n' }, | ||
) | ||
expect(status.exitstatus).to be 0 | ||
expect(out).to match('Detected git version 1.8.2') | ||
expect(out).to match('Okay install git and rerun the script.') | ||
expect(err).to eq('') | ||
end | ||
|
||
context 'batch mode' do | ||
it 'prints nothing' do | ||
stubbed_env.stub_command('hash') # confirm git is in PATH | ||
stubbed_env.stub_command('git').outputs('git version 1.8.2') | ||
|
||
out, err, status = stubbed_env.execute_function( | ||
'scripts/newinstall.sh', | ||
func, | ||
{ 'BATCH_FLAG' => 'true' }, | ||
) | ||
|
||
expect(status.exitstatus).to be 0 | ||
expect(out).to eq('') | ||
expect(err).to eq('') | ||
end | ||
end | ||
end | ||
end |