Added new tests for status and commit

This commit is contained in:
Jeremy Cook
2013-12-27 17:04:34 -05:00
parent c432b27c92
commit 8f67188c19
5 changed files with 38 additions and 15 deletions

View File

@@ -1,5 +1,6 @@
# -*- encoding : utf-8 -*-
require 'spec_helper'
require 'capture-output'
describe 'homesick' do
let(:home) { create_construct }
@@ -341,9 +342,19 @@ describe 'homesick' do
end
describe 'status' do
it 'should say "nothing to commit" when there are no changes' do
given_castle('castle_repo')
text = Capture.stdout { homesick.status('castle_repo') }
text.should =~ /nothing to commit \(create\/copy files and use "git add" to track\)$/
end
xit 'needs testing'
it 'should say "Changes to be committed" when there are changes' do
given_castle('castle_repo')
some_rc_file = home.file '.some_rc_file'
homesick.track(some_rc_file.to_s, 'castle_repo')
text = Capture.stdout { homesick.status('castle_repo') }
text.should =~ /Changes to be committed:.*new file:\s*home\/.some_rc_file/m
end
end
describe 'diff' do
@@ -372,12 +383,6 @@ describe 'homesick' do
end
describe 'commit' do
xit 'needs testing'
end
describe 'push' do
xit 'needs testing'
@@ -448,6 +453,16 @@ describe 'homesick' do
end
end
describe 'commit' do
it 'should have a commit message when the commit succeeds' do
given_castle('castle_repo')
some_rc_file = home.file '.a_random_rc_file'
homesick.track(some_rc_file.to_s, 'castle_repo')
text = Capture.stdout { homesick.commit('castle_repo', 'Test message') }
text.should =~ /^\[master \(root-commit\) \w+\] Test message/
end
end
describe 'subdir_file' do
it 'should add the nested files parent to the subdir_file' do

View File

@@ -4,6 +4,7 @@ require 'homesick'
require 'rspec'
require 'rspec/autorun'
require 'construct'
require 'tempfile'
RSpec.configure do |config|
config.include Construct::Helpers
@@ -21,6 +22,8 @@ RSpec.configure do |config|
castles.directory(path) do |castle|
Dir.chdir(castle) do
system 'git init >/dev/null 2>&1'
system 'git config user.email "test@test.com"'
system 'git config user.name "Test Name"'
system "git remote add origin git://github.com/technicalpickles/#{name}.git >/dev/null 2>&1"
if subdirs
subdir_file = castle.join(Homesick::SUBDIR_FILENAME)