Added tests for untested methods.

This commit is contained in:
Jeremy Cook
2014-01-02 10:27:11 -05:00
parent 264d586863
commit 148d18565f

View File

@@ -363,9 +363,26 @@ describe 'homesick' do
end end
describe 'diff' do describe 'diff' do
it 'should output an empty message when there are no changes to commit' do
given_castle('castle_repo')
some_rc_file = home.file '.some_rc_file'
homesick.track(some_rc_file.to_s, 'castle_repo')
Capture.stdout { homesick.commit 'castle_repo', 'Adding a file to the test' }
text = Capture.stdout { homesick.diff('castle_repo') }
text.should eq('')
end
xit 'needs testing' it 'should output a diff message when there are changes to commit' do
given_castle('castle_repo')
some_rc_file = home.file '.some_rc_file'
homesick.track(some_rc_file.to_s, 'castle_repo')
Capture.stdout { homesick.commit 'castle_repo', 'Adding a file to the test' }
File.open(some_rc_file.to_s, 'w') do |file|
file.puts "Some test text"
end
text = Capture.stdout { homesick.diff('castle_repo') }
text.should =~ /diff --git.+Some test text$/m
end
end end
describe 'show_path' do describe 'show_path' do
@@ -379,19 +396,43 @@ describe 'homesick' do
end end
describe 'pull' do describe 'pull' do
it 'should perform a pull, submodule init and update when the given castle exists' do
given_castle('castle_repo')
homesick.stub(:system).once.with('git pull --quiet')
homesick.stub(:system).once.with('git submodule --quiet init')
homesick.stub(:system).once.with('git submodule --quiet update --init --recursive >/dev/null 2>&1')
homesick.pull 'castle_repo'
end
xit 'needs testing' it 'should print an error message when trying to pull a non-existant castle' do
homesick.should_receive("say_status").once.with(:error, /Could not pull castle_repo, expected \/tmp\/construct_container.* exist and contain dotfiles/, :red)
expect { homesick.pull "castle_repo" }.to raise_error(SystemExit)
end
describe '--all' do describe '--all' do
xit 'needs testing' it 'should pull each castle when invoked with --all' do
given_castle('castle_repo')
given_castle('glencairn')
homesick.stub(:system).exactly(2).times.with('git pull --quiet')
homesick.stub(:system).exactly(2).times.with('git submodule --quiet init')
homesick.stub(:system).exactly(2).times.with('git submodule --quiet update --init --recursive >/dev/null 2>&1')
Capture.stdout { Capture.stderr { homesick.invoke 'pull', [], all: true } }
end
end end
end end
describe 'push' do describe 'push' do
it 'should perform a git push on the given castle' do
given_castle('castle_repo')
homesick.stub(:system).once.with('git push')
homesick.push 'castle_repo'
end
xit 'needs testing' it 'should print an error message when trying to push a non-existant castle' do
homesick.should_receive("say_status").once.with(:error, /Could not push castle_repo, expected \/tmp\/construct_container.* exist and contain dotfiles/, :red)
expect { homesick.push "castle_repo" }.to raise_error(SystemExit)
end
end end
describe 'track' do describe 'track' do
@@ -560,7 +601,7 @@ describe 'homesick' do
it "returns an error message when the $EDITOR environment variable is not set" do it "returns an error message when the $EDITOR environment variable is not set" do
ENV.stub(:[]).with('EDITOR').and_return(nil) # Set the default editor to make sure it fails. ENV.stub(:[]).with('EDITOR').and_return(nil) # Set the default editor to make sure it fails.
homesick.should_receive("say_status").once.with(:error,"The $EDITOR environment variable must be set to use this command", :red) homesick.should_receive("say_status").once.with(:error, "The $EDITOR environment variable must be set to use this command", :red)
expect { homesick.open "castle_repo" }.to raise_error(SystemExit) expect { homesick.open "castle_repo" }.to raise_error(SystemExit)
end end