git_shizzle 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/.rspec +3 -0
  4. data/Gemfile +3 -0
  5. data/Gemfile.lock +71 -0
  6. data/Guardfile +23 -0
  7. data/Thorfile +5 -0
  8. data/bin/quick-git +8 -0
  9. data/doc.txt +8 -0
  10. data/git_shizzle.gemspec +42 -0
  11. data/lib/commands.rb +86 -0
  12. data/lib/git_shizzle/cli.rb +29 -0
  13. data/lib/git_shizzle/dsl/command.rb +41 -0
  14. data/lib/git_shizzle/dsl/command_collection.rb +50 -0
  15. data/lib/git_shizzle/dsl/command_context.rb +19 -0
  16. data/lib/git_shizzle/dsl/command_definition_error.rb +15 -0
  17. data/lib/git_shizzle/dsl/command_not_found_error.rb +9 -0
  18. data/lib/git_shizzle/dsl/dsl.rb +27 -0
  19. data/lib/git_shizzle/dsl/duplicate_command_definition_error.rb +9 -0
  20. data/lib/git_shizzle/dsl/no_command_file_found_error.rb +5 -0
  21. data/lib/git_shizzle/dsl.rb +8 -0
  22. data/lib/git_shizzle/error.rb +5 -0
  23. data/lib/git_shizzle/git/file.rb +42 -0
  24. data/lib/git_shizzle/git/git.rb +67 -0
  25. data/lib/git_shizzle/git.rb +8 -0
  26. data/lib/git_shizzle/index_specifications/base.rb +31 -0
  27. data/lib/git_shizzle/index_specifications/combined.rb +51 -0
  28. data/lib/git_shizzle/index_specifications/errors.rb +21 -0
  29. data/lib/git_shizzle/index_specifications/everything.rb +17 -0
  30. data/lib/git_shizzle/index_specifications/exclusive_range.rb +24 -0
  31. data/lib/git_shizzle/index_specifications/file.rb +22 -0
  32. data/lib/git_shizzle/index_specifications/range.rb +24 -0
  33. data/lib/git_shizzle/index_specifications.rb +10 -0
  34. data/lib/git_shizzle/version.rb +5 -0
  35. data/lib/git_shizzle.rb +53 -0
  36. data/spec/git-shizzle/builtin_commands/checkout_spec.rb +49 -0
  37. data/spec/git-shizzle/builtin_commands/diff_cached_spec.rb +53 -0
  38. data/spec/git-shizzle/builtin_commands/diff_spec.rb +49 -0
  39. data/spec/git-shizzle/builtin_commands/stage_patch_spec.rb +32 -0
  40. data/spec/git-shizzle/builtin_commands/stage_spec.rb +75 -0
  41. data/spec/git-shizzle/builtin_commands/track_spec.rb +41 -0
  42. data/spec/git-shizzle/builtin_commands/unstage_spec.rb +68 -0
  43. data/spec/git-shizzle/command_spec.rb +14 -0
  44. data/spec/git-shizzle/dsl_spec.rb +48 -0
  45. data/spec/git-shizzle/git_spec.rb +15 -0
  46. data/spec/git-shizzle/index_spec.rb +154 -0
  47. data/spec/git-shizzle/status_parser_spec.rb +60 -0
  48. data/spec/helpers/git_repository.rb +46 -0
  49. data/spec/spec_helper.rb +6 -0
  50. metadata +252 -0
@@ -0,0 +1,51 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ module GitShizzle::IndexSpecifications
4
+ class Combined
5
+ def initialize(specs)
6
+ @specs = specs
7
+ end
8
+
9
+ def include?(index)
10
+ index = humanize index
11
+
12
+ @specs.any? do |spec|
13
+ spec.include? index
14
+ end
15
+ end
16
+
17
+ def register_match(index)
18
+ index = humanize index
19
+
20
+ @specs.each do |spec|
21
+ spec.register_match index
22
+ end
23
+ end
24
+
25
+ def unmatched
26
+ []
27
+ end
28
+
29
+ def apply(files)
30
+ result = files.each_with_index.map do |element, index|
31
+ next unless include? index
32
+ register_match index
33
+
34
+ element
35
+ end.compact
36
+
37
+ unmatched_indexes = @specs.map do |spec|
38
+ spec.unmatched
39
+ end.flatten.compact.uniq.sort
40
+
41
+ raise IndexSpecificationError.new(unmatched_indexes) if unmatched_indexes.any?
42
+
43
+ result
44
+ end
45
+
46
+ private
47
+ def humanize(index)
48
+ index + 1
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ module GitShizzle::IndexSpecifications
4
+ class IndexSpecificationError < GitShizzle::Error
5
+ def initialize(indexes)
6
+ super "Could not determine files for indexes: #{indexes.join(', ')}"
7
+ end
8
+ end
9
+
10
+ class IndexParserError < GitShizzle::Error
11
+ def initialize(index)
12
+ super "Could not parse index '#{index}'. Please use numeric indexes or Ruby-style ranges."
13
+ end
14
+ end
15
+
16
+ class NoFilesError < GitShizzle::Error
17
+ def initialize(identifier)
18
+ super "No files for command '#{identifier}'."
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ module GitShizzle::IndexSpecifications
4
+ class Everything < Base
5
+ def include?(index)
6
+ true
7
+ end
8
+
9
+ def unmatched
10
+ []
11
+ end
12
+
13
+ def inspect
14
+ self.class
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ module GitShizzle::IndexSpecifications
4
+ class ExclusiveRange < Base
5
+ def initialize(index)
6
+ spec = index.split('...')
7
+ assert_numeric index, *spec
8
+
9
+ @range = ::Range.new(*spec.map(&:to_i)).to_a[0..-2]
10
+ end
11
+
12
+ def include?(index)
13
+ @range.include? index
14
+ end
15
+
16
+ def unmatched
17
+ @range - matches
18
+ end
19
+
20
+ def inspect
21
+ "#{self.class}: #{@range.inspect}"
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ module GitShizzle::IndexSpecifications
4
+ class File < Base
5
+ def initialize(index)
6
+ assert_numeric index
7
+ @index = index.to_i
8
+ end
9
+
10
+ def include?(index)
11
+ @index == index
12
+ end
13
+
14
+ def unmatched
15
+ ([] << @index) - matches
16
+ end
17
+
18
+ def inspect
19
+ "#{self.class}: #{@index}"
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ module GitShizzle::IndexSpecifications
4
+ class Range < Base
5
+ def initialize(index)
6
+ spec = index.split('..')
7
+ assert_numeric index, *spec
8
+
9
+ @range = ::Range.new(*spec.map(&:to_i)).to_a
10
+ end
11
+
12
+ def include?(index)
13
+ @range.include? index
14
+ end
15
+
16
+ def unmatched
17
+ @range - matches
18
+ end
19
+
20
+ def inspect
21
+ "#{self.class}: #{@range.inspect}"
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,10 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'git_shizzle/index_specifications/base'
4
+
5
+ Dir["#{File.dirname(__FILE__)}/index_specifications/*.rb"].each do |path|
6
+ require "git_shizzle/index_specifications/#{File.basename(path, '.rb')}"
7
+ end
8
+
9
+ module GitShizzle::IndexSpecifications
10
+ end
@@ -0,0 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ module GitShizzle
4
+ VERSION = '0.2.6'
5
+ end
@@ -0,0 +1,53 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'git_shizzle/error'
4
+ require 'git_shizzle/dsl'
5
+ require 'git_shizzle/git'
6
+ require 'git_shizzle/index_specifications'
7
+
8
+ module GitShizzle
9
+
10
+ class QuickGit
11
+ def initialize(git = Git::Git.new(Dir.pwd))
12
+ @git = git
13
+ @commands = GitShizzle::Dsl::CommandCollection.new
14
+ @commands.load
15
+ end
16
+
17
+ def run(command, *indexes)
18
+ cmd = @commands.find command
19
+ files = changes_for(indexes, cmd)
20
+
21
+ cmd.invoke @git, files
22
+ end
23
+
24
+ def method_missing(sym, *args)
25
+ run(sym, *args)
26
+ end
27
+
28
+ private
29
+ def create_index_specification(indexes)
30
+ specs = indexes.map { |index|
31
+ case index
32
+ when /\.\.\./
33
+ IndexSpecifications::ExclusiveRange.new(index)
34
+ when /\.\./
35
+ IndexSpecifications::Range.new(index)
36
+ when /\./
37
+ IndexSpecifications::Everything.new
38
+ else
39
+ IndexSpecifications::File.new(index)
40
+ end
41
+ }
42
+
43
+ IndexSpecifications::Combined.new specs
44
+ end
45
+
46
+ def changes_for(indexes, command)
47
+ files = command.applicable_files(@git.status)
48
+
49
+ spec = create_index_specification indexes
50
+ spec.apply files
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,49 @@
1
+ require File.join(File.dirname(__FILE__), '../../spec_helper')
2
+ require 'git_shizzle'
3
+
4
+ describe 'Checkout files by index' do
5
+
6
+ let(:git) { GitShizzle::Git::Git.new(repo) }
7
+ subject { GitShizzle::QuickGit.new(git) }
8
+
9
+ context 'repository with modified files' do
10
+ before (:each) do
11
+ %w{ deleted modified }.each { |f| create f; stage f }
12
+ `git commit --message Blah`
13
+
14
+ delete 'deleted'
15
+ modify 'modified'
16
+
17
+ git.status[0].work_tree_status.should == :deleted
18
+ git.status[1].work_tree_status.should == :modified
19
+ end
20
+
21
+ context 'when a modified file is checked out' do
22
+ it 'should run git checkout' do
23
+ git.stub(:command).and_call_original
24
+ git.stub(:command).with(/checkout/, anything)
25
+
26
+ expect(git).to receive(:command).with('checkout --', ['modified'])
27
+
28
+ subject.checkout 2
29
+ end
30
+ end
31
+
32
+ context 'when a deleted file is checked out' do
33
+ it 'should run git checkout' do
34
+ git.stub(:command).and_call_original
35
+ git.stub(:command).with(/checkout/, anything)
36
+
37
+ expect(git).to receive(:command).with('checkout --', ['deleted'])
38
+
39
+ subject.checkout 1
40
+ end
41
+ end
42
+ end
43
+
44
+ context 'when the repository contains no modified files' do
45
+ it 'should fail' do
46
+ expect { subject.checkout 1 }.to raise_error
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,53 @@
1
+ require File.join(File.dirname(__FILE__), '../../spec_helper')
2
+ require 'git_shizzle'
3
+
4
+ describe 'Diff staged/cached files by index' do
5
+
6
+ let(:git) { GitShizzle::Git::Git.new(repo) }
7
+ subject { GitShizzle::QuickGit.new(git) }
8
+
9
+ context 'repository with modified files' do
10
+ before (:each) do
11
+ %w{ deleted modified }.each { |f| create f; stage f }
12
+ `git commit --message Blah`
13
+
14
+ delete 'deleted'
15
+ stage 'deleted'
16
+ modify 'modified'
17
+ stage 'modified'
18
+
19
+ git.status[0].work_tree_status.should == nil
20
+ git.status[0].index_status.should == :deleted
21
+ git.status[1].work_tree_status.should == nil
22
+ git.status[1].index_status.should == :modified
23
+ end
24
+
25
+ context 'when a staged modified file is diffed' do
26
+ it 'should run git diff --cached' do
27
+ git.stub(:command).and_call_original
28
+ git.stub(:command).with(/diff/, anything)
29
+
30
+ expect(git).to receive(:command).with('diff --cached --', ['modified'])
31
+
32
+ subject.diff_cached 2
33
+ end
34
+ end
35
+
36
+ context 'when a staged deleted file is diffed' do
37
+ it 'should run git diff --cached' do
38
+ git.stub(:command).and_call_original
39
+ git.stub(:command).with(/diff/, anything)
40
+
41
+ expect(git).to receive(:command).with('diff --cached --', ['deleted'])
42
+
43
+ subject.diff_cached 1
44
+ end
45
+ end
46
+ end
47
+
48
+ context 'when the repository contains no staged files' do
49
+ it 'should fail' do
50
+ expect { subject.diff_cached 1 }.to raise_error
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,49 @@
1
+ require File.join(File.dirname(__FILE__), '../../spec_helper')
2
+ require 'git_shizzle'
3
+
4
+ describe 'Diff files by index' do
5
+
6
+ let(:git) { GitShizzle::Git::Git.new(repo) }
7
+ subject { GitShizzle::QuickGit.new(git) }
8
+
9
+ context 'repository with modified files' do
10
+ before (:each) do
11
+ %w{ deleted modified }.each { |f| create f; stage f }
12
+ `git commit --message Blah`
13
+
14
+ delete 'deleted'
15
+ modify 'modified'
16
+
17
+ git.status[0].work_tree_status.should == :deleted
18
+ git.status[1].work_tree_status.should == :modified
19
+ end
20
+
21
+ context 'when a modified file is diffed' do
22
+ it 'should run git diff' do
23
+ git.stub(:command).and_call_original
24
+ git.stub(:command).with(/diff/, anything)
25
+
26
+ expect(git).to receive(:command).with('diff --', ['modified'])
27
+
28
+ subject.diff 2
29
+ end
30
+ end
31
+
32
+ context 'when a deleted file is diffed' do
33
+ it 'should run git diff' do
34
+ git.stub(:command).and_call_original
35
+ git.stub(:command).with(/diff/, anything)
36
+
37
+ expect(git).to receive(:command).with('diff --', ['deleted'])
38
+
39
+ subject.diff 1
40
+ end
41
+ end
42
+ end
43
+
44
+ context 'when the repository contains no modified files' do
45
+ it 'should fail' do
46
+ expect { subject.diff 1 }.to raise_error
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,32 @@
1
+ require File.join(File.dirname(__FILE__), '../../spec_helper')
2
+ require 'git_shizzle'
3
+
4
+ describe 'Stage patches by index', :draft => true do
5
+
6
+ let(:git) { GitShizzle::Git::Git.new(repo) }
7
+ subject { GitShizzle::QuickGit.new(git) }
8
+
9
+ context 'repository with modified files' do
10
+ before (:each) do
11
+ %w{ deleted modified }.each { |f| create f; stage f }
12
+ `git commit --message Blah`
13
+
14
+ delete 'deleted'
15
+ modify 'modified'
16
+
17
+ git.status[0].work_tree_status.should == :deleted
18
+ git.status[1].work_tree_status.should == :modified
19
+ end
20
+
21
+ context 'when a modified file is staged' do
22
+ it 'should run git add --patch' do
23
+ git.stub(:command).and_call_original
24
+ git.stub(:command).with(/add/, anything)
25
+
26
+ expect(git).to receive(:command).with('add --patch --', ['modified'])
27
+
28
+ subject.stage_with_patch 2
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,75 @@
1
+ require File.join(File.dirname(__FILE__), '../../spec_helper')
2
+ require 'git_shizzle'
3
+
4
+ describe 'Stage files by index' do
5
+
6
+ let(:git) { GitShizzle::Git::Git.new(repo) }
7
+ subject { GitShizzle::QuickGit.new(git) }
8
+
9
+ context 'repository with modified files' do
10
+ before (:each) do
11
+ %w{ deleted modified }.each { |f| create f; stage f }
12
+ `git commit --message Blah`
13
+
14
+ delete 'deleted'
15
+ modify 'modified'
16
+
17
+ git.status[0].work_tree_status.should == :deleted
18
+ git.status[1].work_tree_status.should == :modified
19
+ end
20
+
21
+ context 'when a deleted file is staged' do
22
+ it 'should run git rm' do
23
+ subject.stage 1
24
+
25
+ git.status[0].index_status.should == :deleted
26
+ git.status[1].index_status.should be_nil
27
+ end
28
+ end
29
+
30
+ context 'when a modified file is staged' do
31
+ it 'should run git add' do
32
+ subject.stage 2
33
+
34
+ git.status[0].index_status.should be_nil
35
+ git.status[1].index_status.should == :modified
36
+ end
37
+ end
38
+
39
+ context 'when a modified and a deleted file is staged' do
40
+ it 'should run git add and git rm' do
41
+ subject.stage 1, 2
42
+
43
+ git.status[0].index_status.should == :deleted
44
+ git.status[1].index_status.should == :modified
45
+ end
46
+ end
47
+ end
48
+
49
+ context 'staged file has been modified' do
50
+ context 'when the file is staged' do
51
+ before do
52
+ %w{ modified }.each { |f| create f; stage f }
53
+ `git commit --message Blah`
54
+
55
+ %w{ modified }.each { |f| modify f; stage f; modify f }
56
+
57
+ git.status[0].index_status.should == :modified
58
+ git.status[0].work_tree_status.should == :modified
59
+ end
60
+
61
+ it 'should run git add' do
62
+ subject.stage 1
63
+
64
+ git.status[0].index_status.should == :modified
65
+ git.status[0].work_tree_status.should be_nil
66
+ end
67
+ end
68
+ end
69
+
70
+ context 'when the repository contains no modified files' do
71
+ it 'should fail' do
72
+ expect { subject.stage 1 }.to raise_error
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,41 @@
1
+ require File.join(File.dirname(__FILE__), '../../spec_helper')
2
+ require 'git_shizzle'
3
+
4
+ describe 'Track files by index' do
5
+
6
+ let(:git) { GitShizzle::Git::Git.new(repo) }
7
+ subject { GitShizzle::QuickGit.new(git) }
8
+
9
+ context 'repository with untracked files' do
10
+ before (:each) do
11
+ create 'untracked-1'
12
+ create 'untracked-2'
13
+
14
+ git.status[0].work_tree_status.should == :untracked
15
+ git.status[1].work_tree_status.should == :untracked
16
+ end
17
+
18
+ context 'when a single file is tracked' do
19
+ it 'should run git add for the file' do
20
+ subject.track 1
21
+
22
+ git.status[0].index_status.should == :added
23
+ git.status[1].index_status.should == :untracked
24
+ end
25
+ end
26
+
27
+ context 'when multiple files are tracked' do
28
+ it 'should run git add for all specified files' do
29
+ subject.track 1, 2
30
+
31
+ git.status.each { |entry| entry.index_status.should == :added }
32
+ end
33
+ end
34
+ end
35
+
36
+ context 'when the repository contains no untracked files' do
37
+ it 'should fail' do
38
+ expect { subject.track 1 }.to raise_error
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,68 @@
1
+ require File.join(File.dirname(__FILE__), '../../spec_helper')
2
+ require 'git_shizzle'
3
+
4
+ describe 'Unstage staged/cached files by index' do
5
+
6
+ let(:git) { GitShizzle::Git::Git.new(repo) }
7
+ subject { GitShizzle::QuickGit.new(git) }
8
+
9
+ context 'repository with modified files' do
10
+ before (:each) do
11
+ %w{ deleted modified }.each { |f| create f; stage f }
12
+ `git commit --message Blah`
13
+
14
+ delete 'deleted'
15
+ stage 'deleted'
16
+ modify 'modified'
17
+ stage 'modified'
18
+ create 'untracked'
19
+ stage 'untracked'
20
+
21
+ git.status[0].work_tree_status.should == nil
22
+ git.status[0].index_status.should == :deleted
23
+ git.status[1].work_tree_status.should == nil
24
+ git.status[1].index_status.should == :modified
25
+ git.status[2].work_tree_status.should == nil
26
+ git.status[2].index_status.should == :added
27
+ end
28
+
29
+ context 'when a staged modified file is unstaged' do
30
+ it 'should run git reset HEAD' do
31
+ git.stub(:command).and_call_original
32
+ git.stub(:command).with(/reset/, anything)
33
+
34
+ expect(git).to receive(:command).with('reset HEAD --', ['modified'])
35
+
36
+ subject.unstage 2
37
+ end
38
+ end
39
+
40
+ context 'when a staged deleted file is unstaged' do
41
+ it 'should run git reset HEAD' do
42
+ git.stub(:command).and_call_original
43
+ git.stub(:command).with(/reset/, anything)
44
+
45
+ expect(git).to receive(:command).with('reset HEAD --', ['deleted'])
46
+
47
+ subject.unstage 1
48
+ end
49
+ end
50
+
51
+ context 'when a staged new file is unstaged' do
52
+ it 'should run git reset HEAD' do
53
+ git.stub(:command).and_call_original
54
+ git.stub(:command).with(/reset/, anything)
55
+
56
+ expect(git).to receive(:command).with('reset HEAD --', ['untracked'])
57
+
58
+ subject.unstage 3
59
+ end
60
+ end
61
+ end
62
+
63
+ context 'when the repository contains no staged files' do
64
+ it 'should fail' do
65
+ expect { subject.unstage 1 }.to raise_error
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,14 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper')
2
+ require 'git_shizzle'
3
+
4
+ describe 'Commands specified on the CLI' do
5
+
6
+ let(:git) { GitShizzle::Git::Git.new(repo) }
7
+ subject { GitShizzle::QuickGit.new(git) }
8
+
9
+ context 'when invoking a command that does not exist' do
10
+ it 'should fail' do
11
+ expect { subject.run(:blah) }.to raise_error(GitShizzle::Dsl::CommandNotFoundError, "Could not find 'blah' command.")
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,48 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper')
2
+ require 'git_shizzle'
3
+
4
+ describe 'Command DSL' do
5
+
6
+ context 'when reading commands' do
7
+ it 'should not accept commands without a definition' do
8
+ commands = GitShizzle::Dsl::CommandCollection.new
9
+ command_spec = <<-EOF
10
+ command :foo
11
+ EOF
12
+
13
+ expect { commands.load command_spec }.to raise_error(GitShizzle::Dsl::CommandDefinitionError, "Command 'foo': #command requires a block.")
14
+ end
15
+ end
16
+
17
+ it 'should not accept duplicate identifiers' do
18
+ commands = GitShizzle::Dsl::CommandCollection.new
19
+ command_spec = <<-EOF
20
+ command :foo do end
21
+ command :foo do end
22
+ EOF
23
+
24
+ expect { commands.load command_spec }.to raise_error(GitShizzle::Dsl::DuplicateCommandDefinitionError, "The 'foo' command was specified twice.")
25
+ end
26
+
27
+ it 'should not accept empty filters' do
28
+ commands = GitShizzle::Dsl::CommandCollection.new
29
+ command_spec = <<-EOF
30
+ command :foo do
31
+ applies_to
32
+ end
33
+ EOF
34
+
35
+ expect { commands.load command_spec }.to raise_error(GitShizzle::Dsl::CommandDefinitionError, "Command 'foo': #applies_to requires a block.")
36
+ end
37
+
38
+ it 'should not accept empty actions' do
39
+ commands = GitShizzle::Dsl::CommandCollection.new
40
+ command_spec = <<-EOF
41
+ command :foo do
42
+ action
43
+ end
44
+ EOF
45
+
46
+ expect { commands.load command_spec }.to raise_error(GitShizzle::Dsl::CommandDefinitionError, "Command 'foo': #action requires a block.")
47
+ end
48
+ end
@@ -0,0 +1,15 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper')
2
+ require 'git_shizzle'
3
+
4
+ describe 'Git Repository' do
5
+
6
+ let(:git) { GitShizzle::Git::Git.new(repo) }
7
+ subject { GitShizzle::QuickGit.new(git) }
8
+
9
+ context 'when invoking a command outside a Git repository' do
10
+ it 'should fail' do
11
+ FileUtils.rm_rf '.git'
12
+ expect { subject.run(:track) }.to raise_error(GitShizzle::Git::GitExecuteError, /Not a git repository/)
13
+ end
14
+ end
15
+ end