Added new tests for status and commit
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -15,6 +15,7 @@ group :development do
|
|||||||
gem "rcov", :platforms => :mri_18
|
gem "rcov", :platforms => :mri_18
|
||||||
gem "simplecov", :platforms => :mri_19
|
gem "simplecov", :platforms => :mri_19
|
||||||
gem "test-construct"
|
gem "test-construct"
|
||||||
|
gem "capture-output", "~> 1.0.0"
|
||||||
if RUBY_VERSION >= '1.9.2'
|
if RUBY_VERSION >= '1.9.2'
|
||||||
gem "rubocop"
|
gem "rubocop"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -90,9 +90,9 @@ class Homesick < Thor
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'commit CASTLE', "Commit the specified castle's changes"
|
desc 'commit CASTLE MESSAGE', "Commit the specified castle's changes"
|
||||||
def commit(name = DEFAULT_CASTLE_NAME)
|
def commit(name = DEFAULT_CASTLE_NAME, message = nil)
|
||||||
commit_castle name
|
commit_castle name, message
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -289,10 +289,10 @@ class Homesick < Thor
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def commit_castle(castle)
|
def commit_castle(castle, message)
|
||||||
check_castle_existance(castle, 'commit')
|
check_castle_existance(castle, 'commit')
|
||||||
inside repos_dir.join(castle) do
|
inside repos_dir.join(castle) do
|
||||||
git_commit_all
|
git_commit_all :message => message
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -64,8 +64,12 @@ class Homesick
|
|||||||
|
|
||||||
def git_commit_all(config = {})
|
def git_commit_all(config = {})
|
||||||
say_status 'git commit all', '', :green unless options[:quiet]
|
say_status 'git commit all', '', :green unless options[:quiet]
|
||||||
|
if config[:message]
|
||||||
|
system "git commit -a -m '#{config[:message]}'" unless options[:pretend]
|
||||||
|
else
|
||||||
system 'git commit -v -a' unless options[:pretend]
|
system 'git commit -v -a' unless options[:pretend]
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def git_add(file, config = {})
|
def git_add(file, config = {})
|
||||||
say_status 'git add file', '', :green unless options[:quiet]
|
say_status 'git add file', '', :green unless options[:quiet]
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
require 'capture-output'
|
||||||
|
|
||||||
describe 'homesick' do
|
describe 'homesick' do
|
||||||
let(:home) { create_construct }
|
let(:home) { create_construct }
|
||||||
@@ -341,9 +342,19 @@ describe 'homesick' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe 'status' do
|
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
|
end
|
||||||
|
|
||||||
describe 'diff' do
|
describe 'diff' do
|
||||||
@@ -372,12 +383,6 @@ describe 'homesick' do
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'commit' do
|
|
||||||
|
|
||||||
xit 'needs testing'
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'push' do
|
describe 'push' do
|
||||||
|
|
||||||
xit 'needs testing'
|
xit 'needs testing'
|
||||||
@@ -448,6 +453,16 @@ describe 'homesick' do
|
|||||||
end
|
end
|
||||||
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
|
describe 'subdir_file' do
|
||||||
|
|
||||||
it 'should add the nested files parent to the subdir_file' do
|
it 'should add the nested files parent to the subdir_file' do
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ require 'homesick'
|
|||||||
require 'rspec'
|
require 'rspec'
|
||||||
require 'rspec/autorun'
|
require 'rspec/autorun'
|
||||||
require 'construct'
|
require 'construct'
|
||||||
|
require 'tempfile'
|
||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.include Construct::Helpers
|
config.include Construct::Helpers
|
||||||
@@ -21,6 +22,8 @@ RSpec.configure do |config|
|
|||||||
castles.directory(path) do |castle|
|
castles.directory(path) do |castle|
|
||||||
Dir.chdir(castle) do
|
Dir.chdir(castle) do
|
||||||
system 'git init >/dev/null 2>&1'
|
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"
|
system "git remote add origin git://github.com/technicalpickles/#{name}.git >/dev/null 2>&1"
|
||||||
if subdirs
|
if subdirs
|
||||||
subdir_file = castle.join(Homesick::SUBDIR_FILENAME)
|
subdir_file = castle.join(Homesick::SUBDIR_FILENAME)
|
||||||
|
|||||||
Reference in New Issue
Block a user