tabtab 0.9.0

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 (77) hide show
  1. data/History.txt +4 -0
  2. data/Manifest.txt +76 -0
  3. data/PostInstall.txt +10 -0
  4. data/README.rdoc +385 -0
  5. data/Rakefile +25 -0
  6. data/bin/install_tabtab +10 -0
  7. data/bin/tabtab +10 -0
  8. data/examples/tabtab.sh +7 -0
  9. data/features/aliases_for_completions.feature +23 -0
  10. data/features/development.feature +19 -0
  11. data/features/different_shells_installation.feature +26 -0
  12. data/features/discovered_gem_app_completions.feature +37 -0
  13. data/features/external_app_completions.feature +24 -0
  14. data/features/file_completions.feature +17 -0
  15. data/features/hide_short_flags.feature +19 -0
  16. data/features/steps/cli.rb +63 -0
  17. data/features/steps/common.rb +211 -0
  18. data/features/steps/completions.rb +15 -0
  19. data/features/steps/configuration.rb +20 -0
  20. data/features/steps/env.rb +17 -0
  21. data/features/steps/gems.rb +18 -0
  22. data/features/steps/shells.rb +3 -0
  23. data/lib/dev_definitions/gem.rb +54 -0
  24. data/lib/dev_definitions/rake.rb +23 -0
  25. data/lib/dev_definitions/script-generate.rb +8 -0
  26. data/lib/dev_definitions/script-server.rb +14 -0
  27. data/lib/install_tabtab/cli.rb +139 -0
  28. data/lib/tabtab.rb +10 -0
  29. data/lib/tabtab/cli.rb +116 -0
  30. data/lib/tabtab/completions.rb +6 -0
  31. data/lib/tabtab/completions/external.rb +39 -0
  32. data/lib/tabtab/completions/file.rb +23 -0
  33. data/lib/tabtab/completions/gems.rb +44 -0
  34. data/lib/tabtab/definitions.rb +28 -0
  35. data/lib/tabtab/definitions/base.rb +146 -0
  36. data/lib/tabtab/definitions/command.rb +47 -0
  37. data/lib/tabtab/definitions/default.rb +41 -0
  38. data/lib/tabtab/definitions/flag.rb +38 -0
  39. data/lib/tabtab/definitions/root.rb +70 -0
  40. data/lib/tabtab/framework_testing.rb +11 -0
  41. data/lib/tabtab/local_config.rb +16 -0
  42. data/lib/tabtab/test/assertions.rb +6 -0
  43. data/lib/tabtab_definitions/cucumber.rb +19 -0
  44. data/lib/tabtab_definitions/github.rb +50 -0
  45. data/lib/tabtab_definitions/newgem.rb +27 -0
  46. data/lib/tabtab_definitions/rails.rb +15 -0
  47. data/lib/tabtab_definitions/rubyforge.rb +17 -0
  48. data/script/console +10 -0
  49. data/script/destroy +14 -0
  50. data/script/generate +14 -0
  51. data/spec/definition_spec.rb +334 -0
  52. data/spec/external_spec.rb +38 -0
  53. data/spec/fixtures/bin/test_app +11 -0
  54. data/spec/fixtures/gems/multi_app/History.txt +2 -0
  55. data/spec/fixtures/gems/multi_app/Manifest.txt +7 -0
  56. data/spec/fixtures/gems/multi_app/Rakefile +25 -0
  57. data/spec/fixtures/gems/multi_app/bin/test_app +11 -0
  58. data/spec/fixtures/gems/multi_app/lib/multi_app.rb +6 -0
  59. data/spec/fixtures/gems/multi_app/lib/tabtab_definitions/some_app.rb +5 -0
  60. data/spec/fixtures/gems/multi_app/multi_app-0.0.1.gem +0 -0
  61. data/spec/fixtures/gems/multi_app/multi_app.gemspec +38 -0
  62. data/spec/fixtures/gems/my_app/History.txt +2 -0
  63. data/spec/fixtures/gems/my_app/Manifest.txt +7 -0
  64. data/spec/fixtures/gems/my_app/Rakefile +25 -0
  65. data/spec/fixtures/gems/my_app/bin/test_app +11 -0
  66. data/spec/fixtures/gems/my_app/lib/my_app.rb +6 -0
  67. data/spec/fixtures/gems/my_app/lib/tabtab_definitions.rb +5 -0
  68. data/spec/fixtures/gems/my_app/my_app-0.0.1.gem +0 -0
  69. data/spec/fixtures/gems/my_app/my_app.gemspec +38 -0
  70. data/spec/framework_testing_spec.rb +55 -0
  71. data/spec/install_tabtab_cli_spec.rb +139 -0
  72. data/spec/spec.opts +1 -0
  73. data/spec/spec_helper.rb +14 -0
  74. data/spec/tabtab_cli_spec.rb +145 -0
  75. data/tasks/rspec.rake +21 -0
  76. data/website/images/tabtab.png +0 -0
  77. metadata +167 -0
@@ -0,0 +1,11 @@
1
+ module TabTab::FrameworkTesting
2
+
3
+ module StringExtensions
4
+ def autocompletable_from?(autocompletion_definition)
5
+ autocompletion_definition.autocompletable?(self)
6
+ end
7
+ end
8
+
9
+ end
10
+
11
+ String.send(:include, TabTab::FrameworkTesting::StringExtensions)
@@ -0,0 +1,16 @@
1
+ require 'yaml'
2
+
3
+ module TabTab::LocalConfig
4
+ def config
5
+ @config ||= begin
6
+ config_file = File.join(home, '.tabtab.yml')
7
+ return {} unless File.exists?(config_file)
8
+ YAML.load(File.read(config_file))
9
+ end
10
+ end
11
+
12
+ def home
13
+ ENV["HOME"] || ENV["HOMEPATH"] || File::expand_path("~")
14
+ end
15
+
16
+ end
@@ -0,0 +1,6 @@
1
+ module TabTab::Test::Assertions
2
+ # assert_completable_to "github network --sort branch list --reverse"
3
+ def assert_completable_to(full_command, root_definition)
4
+ full_command.autocompletable_from?(root_definition)
5
+ end
6
+ end
@@ -0,0 +1,19 @@
1
+ TabTab::Definition.register('cucumber', :import => '--help') do |c|
2
+ c.flags(:color)
3
+ c.flags(:"no-color")
4
+ c.flags(:profile, :p) do
5
+ next [] unless File.exists?('cucumber.yml')
6
+ require 'yaml'
7
+ YAML.load(File.read('cucumber.yml')).keys
8
+ end
9
+ c.flags(:format, :f) do
10
+ help = `cucumber -h`
11
+ languages = help.match(/Available formats:(.*)$/)[1]
12
+ languages.split(/,\s*/)
13
+ end
14
+ c.flags(:language, :a) do
15
+ help = `cucumber -h`
16
+ languages = help.match(/Available languages:(.*)$/)[1]
17
+ languages.split(/,\s*/)
18
+ end
19
+ end
@@ -0,0 +1,50 @@
1
+ TabTab::Definition.register('github') do |c|
2
+ def users
3
+ `github info | grep "^ -" | sed -e "s/ - //" | sed -e "s/ .*$//"`.split("\n")
4
+ end
5
+ def commits
6
+ `github network commits 2> /dev/null | sed -e "s/ .*$//"`.split("\n")
7
+ end
8
+ c.flag :help, :h
9
+ c.command(:fetch, "Fetch from a remote to a local branch.") { users }
10
+ c.command(:"pull-request", "Generate the text for a pull request.") { users }
11
+ c.command :browse, "Open this repo in a web browser."
12
+ c.command :pull, "Pull from a remote." do |pull|
13
+ pull.default { users }
14
+ pull.flag :merge
15
+ end
16
+ # github network list
17
+ # github network --cache list
18
+ # github network --sort branch list --reverse
19
+ # github network --sort branch --cache list
20
+ # github network --author some@one.com --before 2008-10-08 list
21
+ c.command :network, "Project network tools" do |network|
22
+ network.command(:web) { users }
23
+ network.command :fetch
24
+ network.command :list
25
+ network.command :commits
26
+ network.flag :nocache
27
+ network.flag :cache
28
+ network.flag :project
29
+ network.flag(:sort) { %w[date branch author] }
30
+ network.flag :applies
31
+ network.flag :before
32
+ network.flag :after
33
+ network.flag :shas
34
+ network.flag :author
35
+ network.flag :common
36
+ end
37
+ c.command :clone, "Clone a repo." do |clone|
38
+ clone.flag :ssh
39
+ end
40
+ c.command :home, "Open this repo's master branch in a web browser."
41
+ c.command(:ignore) { commits }
42
+ c.command :track do |track|
43
+ track.flag :ssh
44
+ track.flag :private
45
+ track.default { users }
46
+ end
47
+ c.command :info
48
+ c.command(:fetch_all) { users }
49
+ end
50
+
@@ -0,0 +1,27 @@
1
+ TabTab::Definition.register('newgem', :import => true) do |c|
2
+ c.flags :"test-with", :T, "Select your preferred testing framework." do
3
+ %w[ test_unit rspec ]
4
+ end
5
+ c.flags :install, :i, "Installs a generator called install_<generator>." do
6
+ # require "rubigen"
7
+ # RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme]
8
+ # RubiGen::Scripts::Generate.new.run([])
9
+ # TODO - function to return list of available generators
10
+ # TODO - make script/generate work for rubigen + rails
11
+ generators = <<-EOS.strip.split(/,[\s\n]*/)
12
+ application_generator, component_generator, executable, extconf,
13
+ install_jruby, install_rspec, install_test_unit, install_website,
14
+ long_box_theme, plain_theme, rails, rspec_controller, rspec_model, test_unit
15
+ EOS
16
+ generators.grep(/^install_/).map { |name| name.gsub(/^install_/, '') }
17
+ end
18
+ c.flags :ruby, :r do
19
+ ENV['PATH'].split(":").inject([]) do |mem, path|
20
+ %w[ruby macruby jruby].each do |ruby|
21
+ ruby = File.join(path, "ruby")
22
+ mem << ruby if File.exists?(ruby)
23
+ end
24
+ mem
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,15 @@
1
+ TabTab::Definition.register('rails', :import => true) do |c|
2
+ c.flags :database, :d do
3
+ "mysql/oracle/postgresql/sqlite2/sqlite3/frontbase".split('/')
4
+ end
5
+ c.flags :ruby, :r do
6
+ ENV['PATH'].split(":").inject([]) do |mem, path|
7
+ %w[ruby macruby jruby].each do |ruby|
8
+ ruby = File.join(path, ruby)
9
+ mem << ruby if File.exists?(ruby)
10
+ end
11
+ mem
12
+ end
13
+ end
14
+ end
15
+
@@ -0,0 +1,17 @@
1
+ TabTab::Definition.register('rubyforge', :import => true) do |c|
2
+ def projects
3
+ []
4
+ end
5
+ c.command :setup
6
+ c.command(:config) { projects }
7
+ c.command :names
8
+ c.command :login do |login|
9
+ login.flag :username
10
+ login.flag :password
11
+ end
12
+ c.command :create_package
13
+ c.command :add_release
14
+ c.command :add_file
15
+ c.command :delete_package
16
+ end
17
+
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/tabtab.rb'}"
9
+ puts "Loading tabtab gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1,334 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ def setup_definitions
4
+ @definitions = TabTab::Definition::Root.named('myapp') do |c|
5
+ c.command :simple
6
+ c.command :run do
7
+ %w[aaaa bbbb cccc]
8
+ end
9
+ c.command :stop do |stop|
10
+ stop.default do
11
+ %w[aaaa bbbb cccc]
12
+ end
13
+ end
14
+ c.command :multi do |multi|
15
+ multi.command :first
16
+ multi.command :last do
17
+ %w[foo bar tar]
18
+ end
19
+ end
20
+ c.flags :some_flag, :s
21
+ c.flag :flag_and_value do
22
+ %w[xxx yyy zzz]
23
+ end
24
+ end
25
+ end
26
+
27
+ describe TabTab::Definition, "register a complete definition" do
28
+ before(:each) do
29
+ TabTab::Definition::Root.expects(:named).with('someapp', {}).returns(mock)
30
+ TabTab::Definition.register('someapp')
31
+ end
32
+
33
+ it "should register application" do
34
+ TabTab::Definition.registrations.should be_has_key('someapp')
35
+ end
36
+ end
37
+
38
+ describe TabTab::Definition, "select definition via [app_name]" do
39
+ before(:each) do
40
+ TabTab::Definition.expects(:registrations).returns({"someapp" => mock})
41
+ end
42
+
43
+ it "should find definition via Definition[someapp]" do
44
+ TabTab::Definition['someapp'].should_not be_nil
45
+ end
46
+ end
47
+
48
+ describe TabTab::Definition::Root, "can pre-load flags from target's --help output using { :import => '--help' } option" do
49
+ before(:each) do
50
+ app_name = File.dirname(__FILE__) + "/fixtures/gems/my_app/bin/test_app"
51
+ @definitions = TabTab::Definition::Root.named(app_name, :import => '--help') do |c|
52
+ c.command :new_command
53
+ c.command :extra do
54
+ %w[this command overrides default --extra flag from output]
55
+ end
56
+ end
57
+ end
58
+ it "should include -h and --help flags from external apps output" do
59
+ @definitions['help'].should_not be_nil
60
+ @definitions['help'].should be_definition_type(:flag)
61
+ @definitions['h'].should be_definition_type(:flag)
62
+ end
63
+ it "should include new_command" do
64
+ @definitions['new_command'].should be_definition_type(:command)
65
+ end
66
+ it "should override --extra default flag as extra command" do
67
+ @definitions['extra'].should be_definition_type(:command)
68
+ end
69
+ end
70
+
71
+ describe TabTab::Definition::Root, "extract_completions" do
72
+ before(:each) do
73
+ setup_definitions
74
+ end
75
+
76
+ it "should initially return list of all root flags and commands" do
77
+ @definitions.extract_completions('someapp', '').should == ['multi', 'run', 'simple', 'stop', '--flag_and_value', '--some_flag', '-s']
78
+ end
79
+
80
+ it "should return list of all root flags and commands after simple command" do
81
+ @definitions.extract_completions('simple', '').should == ['multi', 'run', 'simple', 'stop', '--flag_and_value', '--some_flag', '-s']
82
+ end
83
+
84
+ it "should return list of all root flags and commands after simple flag" do
85
+ @definitions.extract_completions('--some_flag', '').should == ['multi', 'run', 'simple', 'stop', '--flag_and_value', '--some_flag', '-s']
86
+ end
87
+
88
+ it "should return list of all root flags and commands" do
89
+ @definitions.extract_completions('someapp', '--').should == ['--flag_and_value', '--some_flag']
90
+ end
91
+
92
+ it "should return list of flags and commands for a nested command" do
93
+ @definitions.extract_completions('multi', '').should == ['first', 'last']
94
+ end
95
+
96
+ it "should return list of multi's flags and commands after a simple command/flag" do
97
+ @definitions.extract_completions('first', '').should == ['first', 'last']
98
+ end
99
+ end
100
+
101
+ describe TabTab::Definition::Default, "can yield with different number of arguments" do
102
+ before(:each) do
103
+ @definitions = TabTab::Definition::Root.named('myapp') do |c|
104
+ c.command :zero do |zero|
105
+ zero.default { %w[zero] }
106
+ end
107
+ c.command :one do |one|
108
+ one.default { |current| ['one', current] }
109
+ end
110
+ end
111
+ end
112
+
113
+ it "should run default blocks with zero arguments" do
114
+ tokens = @definitions.extract_completions("zero", "")
115
+ tokens.should == ['zero']
116
+ end
117
+
118
+ it "should run default blocks with one arguments and pass current token as argument" do
119
+ tokens = @definitions.extract_completions('one', 'o')
120
+ tokens.should == ['o', 'one']
121
+ end
122
+
123
+ end
124
+ describe TabTab::Definition::Root, "can parse current cmd-line expression and find active definition" do
125
+ before(:each) do
126
+ setup_definitions
127
+ end
128
+
129
+ it "should parse cmd-line 'myapp' and return nil" do
130
+ @definitions.find_active_definition_for_last_token('myapp').should be_nil
131
+ end
132
+
133
+ it "should parse cmd-line 'myapp simple' and return the command definition" do
134
+ @definitions.find_active_definition_for_last_token('simple').should == @definitions['simple']
135
+ end
136
+
137
+ it "should parse cmd-line 'myapp run' and return the command definition" do
138
+ @definitions.find_active_definition_for_last_token('run').should == @definitions['run']
139
+ end
140
+
141
+ it "should parse cmd-line 'myapp --some_flag' and return the flag definition" do
142
+ @definitions.find_active_definition_for_last_token('--some_flag').should == @definitions['some_flag']
143
+ end
144
+
145
+ it "should parse cmd-line 'myapp -s' and return the flag definition" do
146
+ @definitions.find_active_definition_for_last_token('-s').should == @definitions['some_flag']
147
+ end
148
+
149
+ it "should parse cmd-line 'myapp run dummy_value' and return nil" do
150
+ @definitions.find_active_definition_for_last_token('dummy_value').should be_nil
151
+ end
152
+
153
+ it "should parse cmd-line 'myapp multi' and return the multi command definition" do
154
+ @definitions.find_active_definition_for_last_token('multi').should == @definitions['multi']
155
+ end
156
+
157
+ it "should parse cmd-line 'myapp multi first' and return the multi command definition" do
158
+ @definitions.find_active_definition_for_last_token('first').should == @definitions['multi']['first']
159
+ end
160
+
161
+ it "should parse cmd-line 'myapp multi last' and return the command definition" do
162
+ @definitions.find_active_definition_for_last_token('last').should == @definitions['multi']['last']
163
+ end
164
+
165
+ it "should parse cmd-line 'myapp multi last foo' and return nil" do
166
+ @definitions.find_active_definition_for_last_token('foo').should be_nil
167
+ end
168
+
169
+ it "should parse cmd-line 'myapp --some_flag run' and return the run command definition" do
170
+ @definitions.find_active_definition_for_last_token('run').should == @definitions['run']
171
+ end
172
+ end
173
+
174
+ # TODO - not using these functionality as only given last_token by complete API - remove it??
175
+ describe "tokens_consumed for various" do
176
+ describe TabTab::Definition::Base, "definitions" do
177
+ before(:each) do
178
+ setup_definitions
179
+ end
180
+
181
+ it "should consume 1 token for a simple command" do
182
+ @definitions['simple'].tokens_consumed.should == 1
183
+ end
184
+
185
+ it "should consume 2 tokens for a command with value block" do
186
+ @definitions['run'].tokens_consumed.should == 2
187
+ end
188
+
189
+ it "should consume 1 token for a command with a default value block" do
190
+ @definitions['stop'].tokens_consumed.should == 2
191
+ end
192
+
193
+ it "should consume 1 token for a simple flag" do
194
+ @definitions['some_flag'].tokens_consumed.should == 1
195
+ end
196
+
197
+ it "should consume 2 token for a flag with value block" do
198
+ @definitions['flag_and_value'].tokens_consumed.should == 2
199
+ end
200
+ end
201
+ end
202
+ describe "filtered_completions for" do
203
+ describe TabTab::Definition::Root, "with flags and commands can return all terms for autocomplete" do
204
+ before(:each) do
205
+ setup_definitions
206
+ end
207
+
208
+ it "should return ['simple', 'run', 'stop', 'multi', '--some_flag', '-s'] as root-level completion options unfiltered" do
209
+ @definitions.filtered_completions('').should == ['simple', 'run', 'stop', 'multi', '--some_flag', '-s', '--flag_and_value']
210
+ end
211
+
212
+ it "should return ['--some_flag', '-s'] as root-level completion options filtered by '-'" do
213
+ @definitions.filtered_completions('-').should == ['--some_flag', '-s', '--flag_and_value']
214
+ end
215
+
216
+ it "should return ['aaaa', et] for 'run' command" do
217
+ @definitions['run'].filtered_completions('').should == %w[aaaa bbbb cccc]
218
+ end
219
+
220
+ it "should return ['first', 'last'] for 'multi' command" do
221
+ @definitions['multi'].filtered_completions('').should == ['first', 'last']
222
+ end
223
+
224
+ end
225
+
226
+ describe TabTab::Definition::Base, "for default values" do
227
+ before(:each) do
228
+ setup_definitions
229
+ end
230
+
231
+ it "should find ['aaaa', etc] for the run command via a block" do
232
+ @run = @definitions['run']
233
+ @run.definition_type.should == :command
234
+ @run.filtered_completions('').should == %w[aaaa bbbb cccc]
235
+ end
236
+
237
+ it "should find ['aaaa', etc] for the stop command via a default definition" do
238
+ @stop = @definitions['stop']
239
+ @stop.filtered_completions('').should == %w[aaaa bbbb cccc]
240
+ end
241
+
242
+ it "should find ['xxx', etc] for the flag via a block" do
243
+ @flag = @definitions['--flag_and_value']
244
+ @flag.filtered_completions('').should == %w[xxx yyy zzz]
245
+ end
246
+ end
247
+ end
248
+
249
+ describe TabTab::Definition, "with invalid number of block args" do
250
+ it "should raise an error for invalid root block definition" do
251
+ lambda do
252
+ TabTab::Definition::Root.named('myapp') do |c1, c2|
253
+ end
254
+ end.should raise_error(TabTab::Definition::InvalidDefinitionBlockArguments)
255
+ end
256
+
257
+ it "should raise an error for invalid command block definition" do
258
+ lambda do
259
+ TabTab::Definition::Root.named('myapp') do |c|
260
+ c.command :stop do |arg1, arg2|
261
+ end
262
+ end
263
+ end.should raise_error(TabTab::Definition::InvalidDefinitionBlockArguments)
264
+ end
265
+ end
266
+
267
+ describe TabTab::Definition, "should not yield blocks upon creation" do
268
+ before(:each) do
269
+ @normal_block_was_run, @default_block_was_run, @root_default_block_was_run = 0, 0, 0
270
+ @definitions = TabTab::Definition::Root.named('myapp') do |c|
271
+ c.command :run do
272
+ @normal_block_was_run += 1
273
+ end
274
+ c.command :stop do |stop|
275
+ stop.default do
276
+ @default_block_was_run += 1
277
+ end
278
+ end
279
+ c.default do
280
+ @root_default_block_was_run += 1
281
+ end
282
+ end
283
+ end
284
+ it "should not yield block upon creation" do
285
+ @normal_block_was_run.should == 0
286
+ @default_block_was_run.should == 0
287
+ end
288
+
289
+ it "should not yield root value block" do
290
+ @root_default_block_was_run.should == 0
291
+ end
292
+
293
+ it "should not yield block upon #extract_completions" do
294
+ @definitions.extract_completions('myapp', '')
295
+ @normal_block_was_run.should == 0
296
+ @default_block_was_run.should == 0
297
+ end
298
+ end
299
+
300
+ describe TabTab::Definition, "should not yield command blocks when gathering root options" do
301
+ before(:each) do
302
+ @normal_block_was_run, @default_block_was_run, @root_default_block_was_run = 0, 0, 0
303
+ @definitions = TabTab::Definition::Root.named('myapp') do |c|
304
+ c.command :run do
305
+ @normal_block_was_run += 1
306
+ end
307
+ c.command :stop do |stop|
308
+ stop.default do
309
+ @default_block_was_run += 1
310
+ end
311
+ end
312
+ c.default do
313
+ @root_default_block_was_run += 1
314
+ end
315
+ end
316
+ @definitions.extract_completions('myapp', '')
317
+ end
318
+ it "should not yield block upon creation" do
319
+ @normal_block_was_run.should == 0
320
+ @default_block_was_run.should == 0
321
+ end
322
+
323
+ it "should yield root value block" do
324
+ @root_default_block_was_run.should == 1
325
+ end
326
+
327
+ it "should not yield block upon #extract_completions" do
328
+ @definitions.extract_completions('myapp', '')
329
+ @normal_block_was_run.should == 0
330
+ @default_block_was_run.should == 0
331
+ end
332
+
333
+ it "should be failing in here somewhere - in production these blocks are being run!"
334
+ end