tabtab 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
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,38 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe TabTab::Completions::External, "extract verbose help output" do
4
+ before(:each) do
5
+ options_str = <<-EOS.gsub(/^ /, '')
6
+ Options are ...
7
+ -C, --classic-namespace Put Task and FileTask in the top level namespace
8
+ -D, --describe [PATTERN] Describe the tasks (matching optional PATTERN), then exit.
9
+ -e, --execute CODE Execute some Ruby code and exit.
10
+ -p, --execute-print CODE Execute some Ruby code, print the result, then exit.
11
+ -P, --prereqs Display the tasks and dependencies, then exit.
12
+ --rakelib
13
+ -G, --no-system, --nosystem Use standard project Rakefile search paths, ignore system wide rakefiles.
14
+ -h, -H, --help Display this help message.
15
+
16
+ Options:
17
+ -r, --ruby=path Path to the Ruby binary of your choice (otherwise scripts use env, dispatchers current path).
18
+ Default: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
19
+ -d, --database=name Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite2/sqlite3/frontbase/ibm_db).
20
+ Default: sqlite3
21
+ -f, --freeze Freeze Rails in vendor/rails from the gems generating the skeleton
22
+ Default: false
23
+
24
+ Options:
25
+ -b=BIN_NAME[,BIN_NAME2] Should --ignore inline option
26
+ --bin-name Default: -x
27
+ EOS
28
+ @options = TabTab::Completions::External.new('app_name').extract(options_str)
29
+ end
30
+
31
+ it "should find all options" do
32
+ long_options = %w[--bin-name --classic-namespace --database --describe --execute] +
33
+ %w[--execute-print --freeze --help --no-system --nosystem --prereqs --rakelib --ruby]
34
+ short_options = %w[ -C -D -G -H -P -b -d -e -f -h -p -r]
35
+ expected = long_options + short_options
36
+ @options.should == expected
37
+ end
38
+ end
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ if ARGV.include?('-h') || ARGV.include?('--help')
4
+ puts <<-EOS
5
+ Options:
6
+ -h, --help Shows this help
7
+ -x, --extra Does extra stuff
8
+ EOS
9
+ else
10
+ puts "This is a friendly app. Use -h or --help to see options"
11
+ end
@@ -0,0 +1,2 @@
1
+ require "rubygems"
2
+
@@ -0,0 +1,7 @@
1
+ History.txt
2
+ Manifest.txt
3
+ Rakefile
4
+ bin/test_app
5
+ lib/multi_app.rb
6
+ lib/tabtab_definitions/some_app.rb
7
+ multi_app.gemspec
@@ -0,0 +1,25 @@
1
+ %w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
2
+ require File.dirname(__FILE__) + '/lib/multi_app'
3
+
4
+ # Generate all the Rake tasks
5
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
6
+ $hoe = Hoe.new('multi_app', MultiApp::VERSION) do |p|
7
+ p.developer('Dr Nic Williams', 'drnicwilliams@gmail.com')
8
+ p.summary = "Multiple CLI apps + in-built autocompletions"
9
+ p.description = "Multiple CLI apps + in-built autocompletions"
10
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
11
+ p.extra_dev_deps = [
12
+ ['newgem', ">= #{::Newgem::VERSION}"]
13
+ ]
14
+
15
+ p.clean_globs |= %w[**/.DS_Store tmp *.log]
16
+ path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
17
+ p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
18
+ p.rsync_args = '-av --delete --ignore-errors'
19
+ end
20
+
21
+ require 'newgem/tasks' # load /tasks/*.rake
22
+ Dir['tasks/**/*.rake'].each { |t| load t }
23
+
24
+ # TODO - want other tests/tasks run by default? Add them to the list
25
+ # task :default => [:spec, :features]
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ if ARGV.include?('-h') || ARGV.include?('--help')
4
+ puts <<-EOS
5
+ Options:
6
+ -h, --help Shows this help
7
+ -x, --extra Does extra stuff
8
+ EOS
9
+ else
10
+ puts "This is a friendly app. Use -h or --help to see options"
11
+ end
@@ -0,0 +1,6 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ module MultiApp
5
+ VERSION = '0.0.1'
6
+ end
@@ -0,0 +1,5 @@
1
+ TabTab::Definition.register('test_app') do |c|
2
+ c.flags :help, :h, "help"
3
+ c.flags :extra, :x
4
+ end
5
+
@@ -0,0 +1,38 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{multi_app}
5
+ s.version = "0.0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Dr Nic Williams"]
9
+ s.date = %q{2008-11-23}
10
+ s.default_executable = %q{test_app}
11
+ s.description = %q{Multiple CLI apps + in-built autocompletions}
12
+ s.email = ["drnicwilliams@gmail.com"]
13
+ s.executables = ["test_app"]
14
+ s.extra_rdoc_files = ["History.txt", "Manifest.txt"]
15
+ s.files = ["History.txt", "Manifest.txt", "Rakefile", "bin/test_app", "lib/multi_app.rb", "lib/tabtab_definitions/some_app.rb", "multi_app.gemspec"]
16
+ s.has_rdoc = true
17
+ s.rdoc_options = ["--main", "README.txt"]
18
+ s.require_paths = ["lib"]
19
+ s.rubyforge_project = %q{multi_app}
20
+ s.rubygems_version = %q{1.3.1}
21
+ s.summary = %q{Multiple CLI apps + in-built autocompletions}
22
+
23
+ if s.respond_to? :specification_version then
24
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
+ s.specification_version = 2
26
+
27
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
+ s.add_development_dependency(%q<newgem>, [">= 1.1.0"])
29
+ s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
30
+ else
31
+ s.add_dependency(%q<newgem>, [">= 1.1.0"])
32
+ s.add_dependency(%q<hoe>, [">= 1.8.0"])
33
+ end
34
+ else
35
+ s.add_dependency(%q<newgem>, [">= 1.1.0"])
36
+ s.add_dependency(%q<hoe>, [">= 1.8.0"])
37
+ end
38
+ end
@@ -0,0 +1,2 @@
1
+ require "rubygems"
2
+
@@ -0,0 +1,7 @@
1
+ History.txt
2
+ Manifest.txt
3
+ Rakefile
4
+ bin/test_app
5
+ lib/my_app.rb
6
+ lib/tabtab_definitions.rb
7
+ my_app.gemspec
@@ -0,0 +1,25 @@
1
+ %w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
2
+ require File.dirname(__FILE__) + '/lib/my_app'
3
+
4
+ # Generate all the Rake tasks
5
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
6
+ $hoe = Hoe.new('my_app', MyApp::VERSION) do |p|
7
+ p.developer('Dr Nic Williams', 'drnicwilliams@gmail.com')
8
+ p.summary = "Simple CLI app + in-built autocompletions"
9
+ p.description = "Simple CLI app + in-built autocompletions"
10
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
11
+ p.extra_dev_deps = [
12
+ ['newgem', ">= #{::Newgem::VERSION}"]
13
+ ]
14
+
15
+ p.clean_globs |= %w[**/.DS_Store tmp *.log]
16
+ path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
17
+ p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
18
+ p.rsync_args = '-av --delete --ignore-errors'
19
+ end
20
+
21
+ require 'newgem/tasks' # load /tasks/*.rake
22
+ Dir['tasks/**/*.rake'].each { |t| load t }
23
+
24
+ # TODO - want other tests/tasks run by default? Add them to the list
25
+ # task :default => [:spec, :features]
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ if ARGV.include?('-h') || ARGV.include?('--help')
4
+ puts <<-EOS
5
+ Options:
6
+ -h, --help Shows this help
7
+ -x, --extra Does extra stuff
8
+ EOS
9
+ else
10
+ puts "This is a friendly app. Use -h or --help to see options"
11
+ end
@@ -0,0 +1,6 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ module MyApp
5
+ VERSION = '0.0.1'
6
+ end
@@ -0,0 +1,5 @@
1
+ TabTab::Definition.register('test_app') do |c|
2
+ c.flags :help, :h, "help"
3
+ c.flags :extra, :x
4
+ end
5
+
@@ -0,0 +1,38 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{my_app}
5
+ s.version = "0.0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Dr Nic Williams"]
9
+ s.date = %q{2008-11-23}
10
+ s.default_executable = %q{test_app}
11
+ s.description = %q{Simple CLI app + in-built autocompletions}
12
+ s.email = ["drnicwilliams@gmail.com"]
13
+ s.executables = ["test_app"]
14
+ s.extra_rdoc_files = ["History.txt", "Manifest.txt"]
15
+ s.files = ["History.txt", "Manifest.txt", "Rakefile", "bin/test_app", "lib/my_app.rb", "lib/tabtab_definitions.rb", "my_app.gemspec"]
16
+ s.has_rdoc = true
17
+ s.rdoc_options = ["--main", "README.txt"]
18
+ s.require_paths = ["lib"]
19
+ s.rubyforge_project = %q{my_app}
20
+ s.rubygems_version = %q{1.3.1}
21
+ s.summary = %q{Simple CLI app + in-built autocompletions}
22
+
23
+ if s.respond_to? :specification_version then
24
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
+ s.specification_version = 2
26
+
27
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
+ s.add_development_dependency(%q<newgem>, [">= 1.1.0"])
29
+ s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
30
+ else
31
+ s.add_dependency(%q<newgem>, [">= 1.1.0"])
32
+ s.add_dependency(%q<hoe>, [">= 1.8.0"])
33
+ end
34
+ else
35
+ s.add_dependency(%q<newgem>, [">= 1.1.0"])
36
+ s.add_dependency(%q<hoe>, [">= 1.8.0"])
37
+ end
38
+ end
@@ -0,0 +1,55 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+ require "tabtab/framework_testing"
3
+
4
+ describe TabTab::FrameworkTesting, "can be auto-completed with simple flag" do
5
+ before(:each) do
6
+ @definitions = TabTab::Definition::Root.named('myapp') do |c|
7
+ c.flags :flag, :f
8
+ end
9
+ end
10
+
11
+ it "should allow 'myapp --flag'" do
12
+ 'myapp --flag'.should be_autocompletable_from(@definitions)
13
+ end
14
+ end
15
+
16
+ describe TabTab::FrameworkTesting, "can be auto-completed with simple command" do
17
+ before(:each) do
18
+ @definitions = TabTab::Definition::Root.named('myapp') do |c|
19
+ c.command :run
20
+ c.command :stop
21
+ end
22
+ end
23
+
24
+ %w[run stop].each do |cmd|
25
+ it "should allow 'myapp #{cmd}'" do
26
+ "myapp #{cmd}".should be_autocompletable_from(@definitions)
27
+ end
28
+ end
29
+ end
30
+
31
+ describe TabTab::FrameworkTesting, "can be auto-completed with command and an argument" do
32
+ before(:each) do
33
+ @definitions = TabTab::Definition::Root.named('myapp') do |c|
34
+ c.command :run do
35
+ %w[aaaa bbbb cccc]
36
+ end
37
+ c.command :stop do |stop|
38
+ stop.default do
39
+ %w[aaaa bbbb cccc]
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ it "should allow 'myapp run'" do
46
+ 'myapp run'.should be_autocompletable_from(@definitions)
47
+ end
48
+
49
+ %w[run stop].each do |cmd|
50
+ it "should allow 'myapp #{cmd} bbbb'" do
51
+ "myapp #{cmd} bbbb".should be_autocompletable_from(@definitions)
52
+ end
53
+ end
54
+
55
+ end
@@ -0,0 +1,139 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+ require 'install_tabtab/cli'
3
+
4
+ describe InstallTabTab::CLI, "with --development CLI flag" do
5
+ before(:each) do
6
+ ENV['HOME'] = '/tmp/some/home'
7
+ dev_bin = File.expand_path(File.dirname(__FILE__) + "/../bin/tabtab")
8
+ @cli = InstallTabTab::CLI.new
9
+ Gem.expects(:all_load_paths).returns([])
10
+ @cli.expects(:config).returns({"external" => %w[test_app]}).at_least(2)
11
+ File.expects(:open).with('/tmp/some/home/.tabtab.bash', 'w').returns(mock do
12
+ expects(:<<).with("complete -o default -C '#{dev_bin} --external' test_app\n")
13
+ expects(:close)
14
+ end)
15
+ @stdout_io = StringIO.new
16
+ end
17
+
18
+ it "should point to local dev bin/tabtab instead of global tabtab CLI" do
19
+ @cli.execute(@stdout_io, ['--development'])
20
+ end
21
+ end
22
+
23
+ describe InstallTabTab::CLI, "with --external app flag" do
24
+ before(:each) do
25
+ ENV['HOME'] = '/tmp/some/home'
26
+ @cli = InstallTabTab::CLI.new
27
+ Gem.expects(:all_load_paths).returns([])
28
+ @stdout_io = StringIO.new
29
+ end
30
+
31
+ it "should create a home file .tabtab.bash" do
32
+ @cli.expects(:config).returns({"external" => %w[test_app]}).at_least(2)
33
+ File.expects(:open).with('/tmp/some/home/.tabtab.bash', 'w').returns(mock do
34
+ expects(:<<).with("complete -o default -C 'tabtab --external' test_app\n")
35
+ expects(:close)
36
+ end)
37
+ @cli.execute(@stdout_io, [])
38
+ end
39
+
40
+ it "should create a home file .tabtab.bash for alternate help flag" do
41
+ @cli.expects(:config).returns({"external" => [{"-h" => "test_app"}]}).at_least(2)
42
+ File.expects(:open).with('/tmp/some/home/.tabtab.bash', 'w').returns(mock do
43
+ expects(:<<).with("complete -o default -C 'tabtab --external' test_app\n")
44
+ expects(:close)
45
+ end)
46
+ @cli.execute(@stdout_io, [])
47
+ end
48
+
49
+ it "should create a home file .tabtab.bash for an alias" do
50
+ @cli.expects(:config).returns({"external" => %w[test_app], "alias" => { "test" => "test_app" }}).at_least(2)
51
+ File.expects(:open).with('/tmp/some/home/.tabtab.bash', 'w').returns(mock do
52
+ expects(:<<).with("complete -o default -C 'tabtab --external' test_app\n")
53
+ expects(:<<).with("complete -o default -C 'tabtab --external --alias test_app' test\n")
54
+ expects(:close)
55
+ end)
56
+ @cli.execute(@stdout_io, [])
57
+ end
58
+
59
+ it "should create a home file .tabtab.bash for several aliases" do
60
+ @cli.expects(:config).returns({"external" => %w[test_app], "aliases" => { "test" => "test_app", "t" => "test_app" }}).at_least(2)
61
+ File.expects(:open).with('/tmp/some/home/.tabtab.bash', 'w').returns(mock do
62
+ expects(:<<).with("complete -o default -C 'tabtab --external' test_app\n")
63
+ expects(:<<).with("complete -o default -C 'tabtab --external --alias test_app' test\n")
64
+ expects(:<<).with("complete -o default -C 'tabtab --external --alias test_app' t\n")
65
+ expects(:close)
66
+ end)
67
+ @cli.execute(@stdout_io, [])
68
+ end
69
+
70
+ end
71
+
72
+ describe InstallTabTab::CLI, "with --gem GEM_NAME app flag" do
73
+ before(:each) do
74
+ TabTab::Definition.clear
75
+ @cli = InstallTabTab::CLI.new
76
+ @cli.expects(:config).returns({}).at_least(1)
77
+ Gem.expects(:all_load_paths).returns(['/gems/gem_with_tabtabs-1.0.0/lib'])
78
+ Dir.expects(:[]).with('/gems/gem_with_tabtabs-1.0.0/**/tabtab_definitions/**/*.rb').returns([])
79
+ Dir.expects(:[]).with('/gems/gem_with_tabtabs-1.0.0/**/tabtab_definitions.rb').returns(['/gems/gem_with_tabtabs-1.0.0/lib/tabtab_definitions.rb'])
80
+ @cli.expects(:load).with('/gems/gem_with_tabtabs-1.0.0/lib/tabtab_definitions.rb').returns(true)
81
+ TabTab::Definition.expects(:app_names).returns(%w[tabtabbed_app another_app])
82
+ File.expects(:open).with('/tmp/some/home/.tabtab.bash', 'w').returns(mock do
83
+ expects(:<<).with("complete -o default -C 'tabtab --gem gem_with_tabtabs' tabtabbed_app\n")
84
+ expects(:<<).with("complete -o default -C 'tabtab --gem gem_with_tabtabs' another_app\n")
85
+ expects(:close)
86
+ end)
87
+ @stdout_io = StringIO.new
88
+ end
89
+
90
+ it "should create a home file .tabtab.bash" do
91
+ @cli.execute(@stdout_io, [])
92
+ end
93
+
94
+ end
95
+
96
+ describe InstallTabTab::CLI, "with --gem GEM_NAME/PATH flag" do
97
+ before(:each) do
98
+ TabTab::Definition.clear
99
+ @cli = InstallTabTab::CLI.new
100
+ @cli.expects(:config).returns({}).at_least(1)
101
+ Gem.expects(:all_load_paths).returns(['/gems/gem_with_tabtabs-1.0.0/lib'])
102
+ Dir.expects(:[]).with('/gems/gem_with_tabtabs-1.0.0/**/tabtab_definitions.rb').returns([])
103
+ Dir.expects(:[]).with('/gems/gem_with_tabtabs-1.0.0/**/tabtab_definitions/**/*.rb').returns(['/gems/gem_with_tabtabs-1.0.0/lib/tabtab_definitions/tabtabbed_app.rb'])
104
+ @cli.expects(:load).with('/gems/gem_with_tabtabs-1.0.0/lib/tabtab_definitions/tabtabbed_app.rb').returns(true)
105
+ TabTab::Definition.expects(:clear).at_least(1)
106
+ TabTab::Definition.expects(:app_names).returns(%w[tabtabbed_app another_app])
107
+ File.expects(:open).with('/tmp/some/home/.tabtab.bash', 'w').returns(mock do
108
+ expects(:<<).with("complete -o default -C 'tabtab --gem gem_with_tabtabs/lib/tabtab_definitions/tabtabbed_app.rb' tabtabbed_app\n")
109
+ expects(:<<).with("complete -o default -C 'tabtab --gem gem_with_tabtabs/lib/tabtab_definitions/tabtabbed_app.rb' another_app\n")
110
+ expects(:close)
111
+ end)
112
+ @stdout_io = StringIO.new
113
+ end
114
+
115
+ it "should create a home file .tabtab.bash" do
116
+ @cli.execute(@stdout_io, [])
117
+ end
118
+
119
+ end
120
+
121
+ describe InstallTabTab::CLI, "with --file FILE_NAME app flag" do
122
+ before(:each) do
123
+ ENV['HOME'] = '/tmp/some/home'
124
+ @cli = InstallTabTab::CLI.new
125
+ @cli.expects(:config).returns({'file' => {'/path/to/definition.rb' => 'some_app'}}).at_least(2)
126
+ Gem.expects(:all_load_paths).returns([])
127
+ File.expects(:open).with('/tmp/some/home/.tabtab.bash', 'w').returns(mock do
128
+ expects(:<<).with("complete -o default -C 'tabtab --file /path/to/definition.rb' some_app\n")
129
+ expects(:close)
130
+ end)
131
+ @stdout_io = StringIO.new
132
+ end
133
+
134
+ it "should create a home file .tabtab.bash" do
135
+ @cli.execute(@stdout_io, [])
136
+ end
137
+
138
+ end
139
+