twig 1.6 → 1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Twig::Subcommands do
4
4
  describe '.all_names' do
5
5
  it 'returns a unique, sorted list of known subcommands' do
6
- allow(Twig::Subcommands).to receive(:bin_dir_paths) { %w[foo/bin bar/bin] }
6
+ stub_const('ENV', ENV.to_hash.merge('PATH' => 'foo/bin:bar/bin'))
7
7
  expect(Dir).to receive(:glob).with('foo/bin/twig-*').
8
8
  and_yield('foo/bin/twig-subcommand-2').
9
9
  and_yield('foo/bin/twig-subcommand-1')
@@ -16,7 +16,7 @@ describe Twig::Subcommands do
16
16
  end
17
17
 
18
18
  it 'returns an empty array if no subcommands are found' do
19
- allow(Twig::Subcommands).to receive(:bin_dir_paths) { %w[foo/bin bar/bin] }
19
+ stub_const('ENV', ENV.to_hash.merge('PATH' => 'foo/bin:bar/bin'))
20
20
  expect(Dir).to receive(:glob).with('foo/bin/twig-*')
21
21
  expect(Dir).to receive(:glob).with('bar/bin/twig-*')
22
22
 
@@ -26,4 +26,37 @@ describe Twig::Subcommands do
26
26
  end
27
27
  end
28
28
 
29
+ describe '.exec_subcommand_if_any' do
30
+ before :each do
31
+ @branch_name = 'test'
32
+ allow(Twig).to receive(:run)
33
+ end
34
+
35
+ it 'recognizes a subcommand' do
36
+ subcommand_name = 'foo'
37
+ subcommand_path = '/path/to/bin/twig-foo'
38
+ expect(Twig).to receive(:run).with('which twig-foo 2>/dev/null').
39
+ and_return(subcommand_path)
40
+ expect(Twig::Subcommands).to receive(:exec).with(subcommand_path) { exit }
41
+
42
+ # Since we're stubbing `exec` (with an expectation), we still need it
43
+ # to exit early like the real implementation. The following handles the
44
+ # exit somewhat gracefully.
45
+ expect {
46
+ Twig::Subcommands.exec_subcommand_if_any([subcommand_name])
47
+ }.to raise_exception { |exception|
48
+ expect(exception).to be_a(SystemExit)
49
+ expect(exception.status).to eq(0)
50
+ }
51
+ end
52
+
53
+ it 'does not recognize a subcommand' do
54
+ subcommand_name = 'foo'
55
+ expect(Twig).to receive(:run).
56
+ with('which twig-foo 2>/dev/null').and_return('')
57
+ expect(Twig::Subcommands).not_to receive(:exec)
58
+
59
+ Twig::Subcommands.exec_subcommand_if_any([subcommand_name])
60
+ end
61
+ end
29
62
  end
@@ -5,32 +5,31 @@ describe Twig::System do
5
5
  it 'returns true if `host_os` is `windows`' do
6
6
  expect(RbConfig::CONFIG).to receive(:[]).with('host_os').
7
7
  and_return('windows')
8
- expect(Twig::System.windows?).to be_true
8
+ expect(Twig::System.windows?).to be_truthy
9
9
  end
10
10
 
11
11
  it 'returns true if `host_os` is `win32`' do
12
12
  expect(RbConfig::CONFIG).to receive(:[]).with('host_os').
13
13
  and_return('win32')
14
- expect(Twig::System.windows?).to be_true
14
+ expect(Twig::System.windows?).to be_truthy
15
15
  end
16
16
 
17
17
  it 'returns true if `host_os` is Cygwin' do
18
18
  expect(RbConfig::CONFIG).to receive(:[]).with('host_os').
19
19
  and_return('cygwin')
20
- expect(Twig::System.windows?).to be_true
20
+ expect(Twig::System.windows?).to be_truthy
21
21
  end
22
22
 
23
23
  it 'returns true if `host_os` is MinGW' do
24
24
  expect(RbConfig::CONFIG).to receive(:[]).with('host_os').
25
25
  and_return('mingw')
26
- expect(Twig::System.windows?).to be_true
26
+ expect(Twig::System.windows?).to be_truthy
27
27
  end
28
28
 
29
29
  it 'returns false if `host_os` is `darwin` (OS X)' do
30
30
  expect(RbConfig::CONFIG).to receive(:[]).with('host_os').
31
31
  and_return('darwin')
32
- expect(Twig::System.windows?).to be_false
32
+ expect(Twig::System.windows?).to be_falsy
33
33
  end
34
-
35
34
  end
36
35
  end
@@ -3,37 +3,37 @@ require 'spec_helper'
3
3
  describe Twig::Util do
4
4
  describe '.numeric?' do
5
5
  it 'returns true if an object is numeric' do
6
- expect(Twig::Util.numeric?(1)).to be_true
7
- expect(Twig::Util.numeric?('1')).to be_true
6
+ expect(Twig::Util.numeric?(1)).to eql(true)
7
+ expect(Twig::Util.numeric?('1')).to eql(true)
8
8
  end
9
9
 
10
10
  it 'returns false if an object is not numeric' do
11
- expect(Twig::Util.numeric?('x')).to be_false
12
- expect(Twig::Util.numeric?([])).to be_false
13
- expect(Twig::Util.numeric?({})).to be_false
11
+ expect(Twig::Util.numeric?('x')).to eql(false)
12
+ expect(Twig::Util.numeric?([])).to eql(false)
13
+ expect(Twig::Util.numeric?({})).to eql(false)
14
14
  end
15
15
  end
16
16
 
17
17
  describe '.truthy?' do
18
18
  it 'returns true if an object is truthy' do
19
- expect(Twig::Util.truthy?('true')).to be_true
20
- expect(Twig::Util.truthy?('TRUE')).to be_true
21
- expect(Twig::Util.truthy?(true)).to be_true
22
- expect(Twig::Util.truthy?('yes')).to be_true
23
- expect(Twig::Util.truthy?('YES')).to be_true
24
- expect(Twig::Util.truthy?('y')).to be_true
25
- expect(Twig::Util.truthy?('Y')).to be_true
26
- expect(Twig::Util.truthy?('on')).to be_true
27
- expect(Twig::Util.truthy?('ON')).to be_true
28
- expect(Twig::Util.truthy?('1')).to be_true
29
- expect(Twig::Util.truthy?(1)).to be_true
19
+ expect(Twig::Util.truthy?('true')).to eql(true)
20
+ expect(Twig::Util.truthy?('TRUE')).to eql(true)
21
+ expect(Twig::Util.truthy?(true)).to eql(true)
22
+ expect(Twig::Util.truthy?('yes')).to eql(true)
23
+ expect(Twig::Util.truthy?('YES')).to eql(true)
24
+ expect(Twig::Util.truthy?('y')).to eql(true)
25
+ expect(Twig::Util.truthy?('Y')).to eql(true)
26
+ expect(Twig::Util.truthy?('on')).to eql(true)
27
+ expect(Twig::Util.truthy?('ON')).to eql(true)
28
+ expect(Twig::Util.truthy?('1')).to eql(true)
29
+ expect(Twig::Util.truthy?(1)).to eql(true)
30
30
  end
31
31
 
32
32
  it 'returns false if an object is falsy' do
33
- expect(Twig::Util.truthy?('false')).to be_false
34
- expect(Twig::Util.truthy?(false)).to be_false
35
- expect(Twig::Util.truthy?('yep')).to be_false
36
- expect(Twig::Util.truthy?('sure, why not')).to be_false
33
+ expect(Twig::Util.truthy?('false')).to eql(false)
34
+ expect(Twig::Util.truthy?(false)).to eql(false)
35
+ expect(Twig::Util.truthy?('yep')).to eql(false)
36
+ expect(Twig::Util.truthy?('sure, why not')).to eql(false)
37
37
  end
38
38
  end
39
39
 
data/spec/twig_spec.rb CHANGED
@@ -83,6 +83,21 @@ describe Twig do
83
83
  end
84
84
  end
85
85
 
86
+ describe '#target_branch' do
87
+ before :each do
88
+ @twig = Twig.new
89
+ end
90
+
91
+ it 'returns a Branch object for the target branch name' do
92
+ branch_name = 'feature-branch'
93
+ allow(@twig).to receive(:target_branch_name).and_return(branch_name)
94
+
95
+ branch = @twig.target_branch
96
+
97
+ expect(branch.name).to eq(branch_name)
98
+ end
99
+ end
100
+
86
101
  describe '#branches' do
87
102
  before :each do
88
103
  @twig = Twig.new
@@ -93,10 +108,10 @@ describe Twig do
93
108
  fix_everything
94
109
  ]
95
110
  commit_times = [
96
- Twig::CommitTime.new(Time.now - 86400 * 10, '10 days ago'),
97
- Twig::CommitTime.new(Time.now - 86400 * 20, '20 days ago'),
98
- Twig::CommitTime.new(Time.now - 86400 * 30, '30 days ago'),
99
- Twig::CommitTime.new(Time.now - 86400 * 40, '40 days ago')
111
+ Twig::CommitTime.new(Time.now - 86400 * 10),
112
+ Twig::CommitTime.new(Time.now - 86400 * 20),
113
+ Twig::CommitTime.new(Time.now - 86400 * 30),
114
+ Twig::CommitTime.new(Time.now - 86400 * 40)
100
115
  ]
101
116
  @branches = [
102
117
  Twig::Branch.new(branch_names[0], :last_commit_time => commit_times[0]),
@@ -212,8 +227,8 @@ describe Twig do
212
227
  @twig = Twig.new
213
228
  @list_headers = '[branch list headers]'
214
229
  commit_times = [
215
- Twig::CommitTime.new(Time.now, '111 days ago'),
216
- Twig::CommitTime.new(Time.now, '222 days ago')
230
+ Twig::CommitTime.new(Time.now),
231
+ Twig::CommitTime.new(Time.now)
217
232
  ]
218
233
  allow(commit_times[0]).to receive(:to_i) { 2000_01_01 }
219
234
  allow(commit_times[0]).to receive(:to_s) { '2000-01-01' }
data/twig.gemspec CHANGED
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  lib = File.expand_path('../lib', __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'twig/homepage'
@@ -21,19 +20,19 @@ Gem::Specification.new do |spec|
21
20
  of time.
22
21
  ].join(' ')
23
22
  spec.post_install_message =
24
- "\n**************************************************************" <<
25
- "\n* *" <<
26
- "\n* Welcome to Twig! *" <<
27
- "\n* *" <<
28
- "\n* Quick start: *" <<
29
- "\n* *" <<
30
- "\n* 1. Run `twig init` to set up tab completion. *" <<
31
- "\n* 2. Run `twig` to list your Git branches. *" <<
32
- "\n* *" <<
33
- "\n* For more info, run `twig --help` or visit *" <<
34
- "\n* #{sprintf('%-59s', Twig::HOMEPAGE) }*" <<
35
- "\n* *" <<
36
- "\n**************************************************************" <<
23
+ "\n*************************************************" \
24
+ "\n* *" \
25
+ "\n* Welcome to Twig! *" \
26
+ "\n* *" \
27
+ "\n* Quick start: *" \
28
+ "\n* *" \
29
+ "\n* 1. Run `twig init` to set up tab completion. *" \
30
+ "\n* 2. Run `twig` to list your Git branches. *" \
31
+ "\n* *" \
32
+ "\n* For more info, run `twig help` or visit *" \
33
+ "\n* #{sprintf('%-46s', Twig::HOMEPAGE) }*" \
34
+ "\n* *" \
35
+ "\n*************************************************" \
37
36
  "\n\n"
38
37
 
39
38
  spec.files = `git ls-files`.split($/)
@@ -45,6 +44,5 @@ Gem::Specification.new do |spec|
45
44
  spec.add_runtime_dependency 'json', '~> 1.7.5'
46
45
  spec.add_runtime_dependency 'launchy', '~> 2.3.0'
47
46
  spec.add_development_dependency 'rake', '~> 0.9.2'
48
- spec.add_development_dependency 'rspec', '~> 2.14.1'
49
- spec.add_development_dependency 'rspec-radar', '~> 0.1.0'
47
+ spec.add_development_dependency 'rspec', '~> 3.0.0'
50
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twig
3
3
  version: !ruby/object:Gem::Version
4
- version: "1.6"
4
+ version: "1.7"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ron DeVera
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2014-03-04 00:00:00 Z
12
+ date: 2014-07-29 00:00:00 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -48,19 +48,9 @@ dependencies:
48
48
  requirements:
49
49
  - - ~>
50
50
  - !ruby/object:Gem::Version
51
- version: 2.14.1
51
+ version: 3.0.0
52
52
  type: :development
53
53
  version_requirements: *id004
54
- - !ruby/object:Gem::Dependency
55
- name: rspec-radar
56
- prerelease: false
57
- requirement: &id005 !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: 0.1.0
62
- type: :development
63
- version_requirements: *id005
64
54
  description: Twig is your personal Git branch assistant. It's a command-line tool for listing your most recent branches, and for remembering branch details for you, like issue tracker ids and todos. It supports subcommands, like automatically fetching statuses from your issue tracking system. It's flexible enough to fit your everyday Git workflow, and will save you a ton of time.
65
55
  email:
66
56
  - hello@rondevera.com
@@ -77,6 +67,7 @@ executables:
77
67
  - twig-init
78
68
  - twig-init-completion
79
69
  - twig-init-completion-bash
70
+ - twig-init-config
80
71
  - twig-rebase
81
72
  extensions: []
82
73
 
@@ -103,10 +94,13 @@ files:
103
94
  - bin/twig-init
104
95
  - bin/twig-init-completion
105
96
  - bin/twig-init-completion-bash
97
+ - bin/twig-init-config
106
98
  - bin/twig-rebase
99
+ - config/twigconfig
107
100
  - lib/twig.rb
108
101
  - lib/twig/branch.rb
109
102
  - lib/twig/cli.rb
103
+ - lib/twig/cli/help.rb
110
104
  - lib/twig/commit_time.rb
111
105
  - lib/twig/display.rb
112
106
  - lib/twig/github.rb
@@ -118,6 +112,7 @@ files:
118
112
  - lib/twig/version.rb
119
113
  - spec/spec_helper.rb
120
114
  - spec/twig/branch_spec.rb
115
+ - spec/twig/cli/help_spec.rb
121
116
  - spec/twig/cli_spec.rb
122
117
  - spec/twig/commit_time_spec.rb
123
118
  - spec/twig/display_spec.rb
@@ -135,19 +130,19 @@ metadata: {}
135
130
 
136
131
  post_install_message: |+
137
132
 
138
- **************************************************************
139
- * *
140
- * Welcome to Twig! *
141
- * *
142
- * Quick start: *
143
- * *
144
- * 1. Run `twig init` to set up tab completion. *
145
- * 2. Run `twig` to list your Git branches. *
146
- * *
147
- * For more info, run `twig --help` or visit *
148
- * http://rondevera.github.io/twig/ *
149
- * *
150
- **************************************************************
133
+ *************************************************
134
+ * *
135
+ * Welcome to Twig! *
136
+ * *
137
+ * Quick start: *
138
+ * *
139
+ * 1. Run `twig init` to set up tab completion. *
140
+ * 2. Run `twig` to list your Git branches. *
141
+ * *
142
+ * For more info, run `twig help` or visit *
143
+ * http://rondevera.github.io/twig/ *
144
+ * *
145
+ *************************************************
151
146
 
152
147
  rdoc_options: []
153
148
 
@@ -166,13 +161,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
161
  requirements: []
167
162
 
168
163
  rubyforge_project:
169
- rubygems_version: 2.0.14
164
+ rubygems_version: 2.2.2
170
165
  signing_key:
171
166
  specification_version: 4
172
167
  summary: Your personal Git branch assistant.
173
168
  test_files:
174
169
  - spec/spec_helper.rb
175
170
  - spec/twig/branch_spec.rb
171
+ - spec/twig/cli/help_spec.rb
176
172
  - spec/twig/cli_spec.rb
177
173
  - spec/twig/commit_time_spec.rb
178
174
  - spec/twig/display_spec.rb