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.
- data/History.txt +4 -0
- data/Manifest.txt +76 -0
- data/PostInstall.txt +10 -0
- data/README.rdoc +385 -0
- data/Rakefile +25 -0
- data/bin/install_tabtab +10 -0
- data/bin/tabtab +10 -0
- data/examples/tabtab.sh +7 -0
- data/features/aliases_for_completions.feature +23 -0
- data/features/development.feature +19 -0
- data/features/different_shells_installation.feature +26 -0
- data/features/discovered_gem_app_completions.feature +37 -0
- data/features/external_app_completions.feature +24 -0
- data/features/file_completions.feature +17 -0
- data/features/hide_short_flags.feature +19 -0
- data/features/steps/cli.rb +63 -0
- data/features/steps/common.rb +211 -0
- data/features/steps/completions.rb +15 -0
- data/features/steps/configuration.rb +20 -0
- data/features/steps/env.rb +17 -0
- data/features/steps/gems.rb +18 -0
- data/features/steps/shells.rb +3 -0
- data/lib/dev_definitions/gem.rb +54 -0
- data/lib/dev_definitions/rake.rb +23 -0
- data/lib/dev_definitions/script-generate.rb +8 -0
- data/lib/dev_definitions/script-server.rb +14 -0
- data/lib/install_tabtab/cli.rb +139 -0
- data/lib/tabtab.rb +10 -0
- data/lib/tabtab/cli.rb +116 -0
- data/lib/tabtab/completions.rb +6 -0
- data/lib/tabtab/completions/external.rb +39 -0
- data/lib/tabtab/completions/file.rb +23 -0
- data/lib/tabtab/completions/gems.rb +44 -0
- data/lib/tabtab/definitions.rb +28 -0
- data/lib/tabtab/definitions/base.rb +146 -0
- data/lib/tabtab/definitions/command.rb +47 -0
- data/lib/tabtab/definitions/default.rb +41 -0
- data/lib/tabtab/definitions/flag.rb +38 -0
- data/lib/tabtab/definitions/root.rb +70 -0
- data/lib/tabtab/framework_testing.rb +11 -0
- data/lib/tabtab/local_config.rb +16 -0
- data/lib/tabtab/test/assertions.rb +6 -0
- data/lib/tabtab_definitions/cucumber.rb +19 -0
- data/lib/tabtab_definitions/github.rb +50 -0
- data/lib/tabtab_definitions/newgem.rb +27 -0
- data/lib/tabtab_definitions/rails.rb +15 -0
- data/lib/tabtab_definitions/rubyforge.rb +17 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/definition_spec.rb +334 -0
- data/spec/external_spec.rb +38 -0
- data/spec/fixtures/bin/test_app +11 -0
- data/spec/fixtures/gems/multi_app/History.txt +2 -0
- data/spec/fixtures/gems/multi_app/Manifest.txt +7 -0
- data/spec/fixtures/gems/multi_app/Rakefile +25 -0
- data/spec/fixtures/gems/multi_app/bin/test_app +11 -0
- data/spec/fixtures/gems/multi_app/lib/multi_app.rb +6 -0
- data/spec/fixtures/gems/multi_app/lib/tabtab_definitions/some_app.rb +5 -0
- data/spec/fixtures/gems/multi_app/multi_app-0.0.1.gem +0 -0
- data/spec/fixtures/gems/multi_app/multi_app.gemspec +38 -0
- data/spec/fixtures/gems/my_app/History.txt +2 -0
- data/spec/fixtures/gems/my_app/Manifest.txt +7 -0
- data/spec/fixtures/gems/my_app/Rakefile +25 -0
- data/spec/fixtures/gems/my_app/bin/test_app +11 -0
- data/spec/fixtures/gems/my_app/lib/my_app.rb +6 -0
- data/spec/fixtures/gems/my_app/lib/tabtab_definitions.rb +5 -0
- data/spec/fixtures/gems/my_app/my_app-0.0.1.gem +0 -0
- data/spec/fixtures/gems/my_app/my_app.gemspec +38 -0
- data/spec/framework_testing_spec.rb +55 -0
- data/spec/install_tabtab_cli_spec.rb +139 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/tabtab_cli_spec.rb +145 -0
- data/tasks/rspec.rake +21 -0
- data/website/images/tabtab.png +0 -0
- metadata +167 -0
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
%w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
|
2
|
+
require File.dirname(__FILE__) + '/lib/tabtab'
|
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('tabtab', TabTab::VERSION) do |p|
|
7
|
+
p.developer('Dr Nic Williams', 'drnicwilliams@gmail.com')
|
8
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
9
|
+
p.post_install_message = 'PostInstall.txt'
|
10
|
+
p.extra_dev_deps = [
|
11
|
+
['newgem', ">= #{::Newgem::VERSION}"],
|
12
|
+
['cucumber', ">= 0.1.8"]
|
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
|
+
remove_task :default
|
25
|
+
task :default => [:spec, :features]
|
data/bin/install_tabtab
ADDED
data/bin/tabtab
ADDED
data/examples/tabtab.sh
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
complete -o default -C "/Users/drnic/gems/tabtab/bin/tabtab --external" curl
|
2
|
+
complete -o default -C "/Users/drnic/gems/tabtab/bin/tabtab --gem my_app" test_app
|
3
|
+
complete -o default -C "/Users/drnic/gems/tabtab/bin/tabtab --file /Users/drnic/Documents/ruby/gems/tabtab/spec/fixtures/gems/my_app/lib/tabtab_definitions/github.rb" github
|
4
|
+
complete -o default -C "/Users/drnic/gems/tabtab/bin/tabtab --file /Users/drnic/Documents/ruby/gems/tabtab/spec/fixtures/gems/my_app/lib/tabtab_definitions/rails.rb" rails
|
5
|
+
complete -o default -C "/Users/drnic/gems/tabtab/bin/tabtab --file /Users/drnic/Documents/ruby/gems/tabtab/spec/fixtures/gems/my_app/lib/tabtab_definitions/script-server.rb" script/server
|
6
|
+
complete -o default -C "/Users/drnic/gems/tabtab/bin/tabtab --file /Users/drnic/Documents/ruby/gems/tabtab/spec/fixtures/gems/my_app/lib/tabtab_definitions/gem.rb" gem
|
7
|
+
complete -o default -C "/Users/drnic/gems/tabtab/bin/tabtab --file /Users/drnic/Documents/ruby/gems/tabtab/spec/fixtures/gems/my_app/lib/tabtab_definitions/rake.rb" rake
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Feature: User can reuse completions for their own aliases
|
2
|
+
In order to minimize cost of duplicating definitions
|
3
|
+
As a command line user that defines aliases
|
4
|
+
I want the tabtab completions for the unaliased application to work for my alias
|
5
|
+
|
6
|
+
Scenario: Add alias for existing completions
|
7
|
+
Given a .tabtab.yml config file
|
8
|
+
And alias 'test_alias' to existing 'test_app'
|
9
|
+
When run local executable 'install_tabtab' with arguments ''
|
10
|
+
Then home file '.tabtab.bash' is created
|
11
|
+
And contents of home file '.tabtab.bash' does match /test_alias/
|
12
|
+
And contents of home file '.tabtab.bash' does match /--file /path/to/file.rb --alias test_app/
|
13
|
+
|
14
|
+
Scenario: An alias maps directly to an app name, that has an existing tabtab definition
|
15
|
+
Given a file 'my_definitions.rb' containing completion definitions
|
16
|
+
When run local executable 'tabtab' with arguments '--file my_definitions.rb --alias test_app test "" test'
|
17
|
+
Then I should see a full list of options for 'test_app'
|
18
|
+
|
19
|
+
Scenario: An alias maps to an app name plus arguments
|
20
|
+
Given a file 'my_definitions.rb' containing completion definitions
|
21
|
+
When run local executable 'tabtab' with arguments '--file my_definitions.rb --alias "test_app -x" test "" test'
|
22
|
+
Then oneday I should see a full list of options for 'test_app'
|
23
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Feature: Development processes of newgem itself (rake tasks)
|
2
|
+
|
3
|
+
As a Newgem maintainer or contributor
|
4
|
+
I want rake tasks to maintain and release the gem
|
5
|
+
So that I can spend time on the tests and code, and not excessive time on maintenance processes
|
6
|
+
|
7
|
+
Scenario: Generate RubyGem
|
8
|
+
Given this project is active project folder
|
9
|
+
And 'pkg' folder is deleted
|
10
|
+
When task 'rake gem' is invoked
|
11
|
+
Then project folder 'pkg' is created
|
12
|
+
And project file with name matching 'pkg/*.gem' is created else you should run "rake manifest" to fix this
|
13
|
+
And gem spec key 'rdoc_options' contains /--mainREADME.rdoc/
|
14
|
+
|
15
|
+
Scenario: Generate .tabtab.bash using dev tabtab CLI instead of gem version
|
16
|
+
Given a .tabtab.yml config file
|
17
|
+
When run local executable 'install_tabtab' with arguments '--development'
|
18
|
+
Then home file '.tabtab.bash' is created
|
19
|
+
And contents of home file '.tabtab.bash' does match /bin\/tabtab/
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Feature: Can install tabtab autocompletions for multiple shells
|
2
|
+
In order to minimize cost of having autocompletion scripts for my personal shell
|
3
|
+
As a Unix command line user
|
4
|
+
I want any tabtab completion definition to work on my shell
|
5
|
+
|
6
|
+
Scenario: I use bash shell
|
7
|
+
Given a bash shell
|
8
|
+
And a .tabtab.yml config file
|
9
|
+
When run local executable 'install_tabtab' with arguments ''
|
10
|
+
Then home file '.tabtab.bash' is created
|
11
|
+
Then external completions are ready to be installed for applications: rails, test_app
|
12
|
+
|
13
|
+
Scenario: I use fish shell
|
14
|
+
Given a fish shell
|
15
|
+
And a .tabtab.yml config file
|
16
|
+
When run local executable 'install_tabtab' with arguments ''
|
17
|
+
Then home file '.tabtab.fish' is created
|
18
|
+
Then external completions are ready to be installed for applications: rails, test_app
|
19
|
+
|
20
|
+
Scenario: I use ksh shell
|
21
|
+
Given a ksh shell
|
22
|
+
And a .tabtab.yml config file
|
23
|
+
When run local executable 'install_tabtab' with arguments ''
|
24
|
+
Then home file '.tabtab.ksh' is created
|
25
|
+
Then external completions are ready to be installed for applications: rails, test_app
|
26
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Feature: Discover completions config script in installed RubyGems
|
2
|
+
In order to minimize cost of using completions
|
3
|
+
As a user of RubyGems that contain completions config scripts
|
4
|
+
I want RubyGems executables to be automatically enabled with auto-completions for my shell
|
5
|
+
|
6
|
+
Scenario: Find and add completions for rubygems' executables via tabtab_definitions.rb file
|
7
|
+
Given a user's RubyGems gem cache
|
8
|
+
And a RubyGem 'my_app' with autocompletions
|
9
|
+
When run local executable 'install_tabtab' with arguments ''
|
10
|
+
Then home file '.tabtab.bash' is created
|
11
|
+
Then gem completions are ready to be installed for applications test_app in gem my_app
|
12
|
+
|
13
|
+
Scenario: Find and add completions for rubygems' executables via tabtab_definitions/ folder
|
14
|
+
Given a user's RubyGems gem cache
|
15
|
+
And a RubyGem 'multi_app' with autocompletions
|
16
|
+
When run local executable 'install_tabtab' with arguments ''
|
17
|
+
Then home file '.tabtab.bash' is created
|
18
|
+
Then gem completions are ready to be installed for application test_app in gem multi_app in file lib/tabtab_definitions/some_app.rb
|
19
|
+
|
20
|
+
Scenario: Activate auto-completions for gem-based app, determine options and return all
|
21
|
+
Given a user's RubyGems gem cache
|
22
|
+
And a RubyGem 'my_app' with autocompletions
|
23
|
+
When run local executable 'tabtab' with arguments '--gem my_app test_app "" test_app'
|
24
|
+
Then I should see a full list of options for 'test_app'
|
25
|
+
|
26
|
+
Scenario: Activate auto-completions for gem-based app, determine partial options and return all
|
27
|
+
Given a user's RubyGems gem cache
|
28
|
+
And a RubyGem 'my_app' with autocompletions
|
29
|
+
When run local executable 'tabtab' with arguments '--gem my_app test_app -- test_app'
|
30
|
+
Then I should not see any short form flags
|
31
|
+
|
32
|
+
Scenario: Activate many auto-completions for gem-based app within tabtab_definitions folder
|
33
|
+
Given a user's RubyGems gem cache
|
34
|
+
And a RubyGem 'multi_app' with autocompletions
|
35
|
+
When run local executable 'tabtab' with arguments '--gem multi_app/lib/tabtab_definitions/some_app.rb test_app "" test_app'
|
36
|
+
Then I should see a full list of options for 'test_app'
|
37
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Feature: Autocompletions for any 3rd-party application's options
|
2
|
+
In order to minimise costs
|
3
|
+
As a command-line application user
|
4
|
+
I want auto-completions for the command-line applications I use
|
5
|
+
|
6
|
+
Scenario: Install configured list of applications into bash completions
|
7
|
+
Given a .tabtab.yml config file
|
8
|
+
When run local executable 'install_tabtab' with arguments ''
|
9
|
+
Then home file '.tabtab.bash' is created
|
10
|
+
And external completions are ready to be installed for applications: rails, test_app
|
11
|
+
|
12
|
+
Scenario: Activate auto-completions for app, determine options and return all
|
13
|
+
Given a .tabtab.yml config file
|
14
|
+
And env variable $PATH includes fixture executables folder
|
15
|
+
When run local executable 'tabtab' with arguments '--external test_app "" test_app'
|
16
|
+
Then I should see a full list of options for 'test_app'
|
17
|
+
|
18
|
+
Scenario: Activate auto-completions for app, determine partial options and return all
|
19
|
+
Given a .tabtab.yml config file
|
20
|
+
And env variable $PATH includes fixture executables folder
|
21
|
+
When run local executable 'tabtab' with arguments '--external test_app -- test_app'
|
22
|
+
Then I should not see any short form flags
|
23
|
+
|
24
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Feature: Autocompletions for app via an explicit definition file
|
2
|
+
In order to minimise costs
|
3
|
+
As a command-line application user
|
4
|
+
I want my own autocompletions for an app, rather than those given by default
|
5
|
+
|
6
|
+
Scenario: Add completions within explicit files
|
7
|
+
Given a .tabtab.yml config file
|
8
|
+
When run local executable 'install_tabtab' with arguments ''
|
9
|
+
Then home file '.tabtab.bash' is created
|
10
|
+
Then file completions are ready to be installed for applications test_app in file /path/to/file.rb
|
11
|
+
|
12
|
+
Scenario: Trigger autocompletions where the definition is in a specific file
|
13
|
+
Given a file 'my_definitions.rb' containing completion definitions
|
14
|
+
When run local executable 'tabtab' with arguments '--file my_definitions.rb test_app "" test_app'
|
15
|
+
Then I should see a full list of options for 'test_app'
|
16
|
+
|
17
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Feature: Do not display short flags (-p) within lists of completions options
|
2
|
+
In order to reduce cost of scanning through lists of completion options
|
3
|
+
As a tabtab user
|
4
|
+
I want to be able to disable short flags and never see them
|
5
|
+
|
6
|
+
Scenario: Explicitly disable short flags via the config file for definitions
|
7
|
+
Given a .tabtab.yml config file
|
8
|
+
And a file 'my_definitions.rb' containing completion definitions
|
9
|
+
And disable short flags
|
10
|
+
When run local executable 'tabtab' with arguments '--file my_definitions.rb test_app "" test_app'
|
11
|
+
Then I should not see any short form flags
|
12
|
+
|
13
|
+
Scenario: Explicitly disable short flags via the config file for externals
|
14
|
+
Given a .tabtab.yml config file
|
15
|
+
And disable short flags
|
16
|
+
And env variable $PATH includes fixture executables folder
|
17
|
+
When run local executable 'tabtab' with arguments '--external test_app "" test_app'
|
18
|
+
Then I should not see any short form flags
|
19
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
Given %r{^a .tabtab.yml config file} do
|
2
|
+
Given "a safe folder"
|
3
|
+
in_home_folder do
|
4
|
+
config = {
|
5
|
+
'external' => %w[rails test_app],
|
6
|
+
'files' => {
|
7
|
+
'/path/to/file.rb' => 'test_app'
|
8
|
+
}
|
9
|
+
}
|
10
|
+
File.open('.tabtab.yml', 'w') do |f|
|
11
|
+
f << config.to_yaml
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Given /^a file '(.*)' containing completion definitions$/ do |file|
|
17
|
+
Given "a safe folder"
|
18
|
+
in_project_folder do
|
19
|
+
File.open(file, "w") do |f|
|
20
|
+
f << <<-RUBY.gsub(/^ /,'')
|
21
|
+
TabTab::Definition.register('test_app') do |c|
|
22
|
+
c.flags :help, :h, "help"
|
23
|
+
c.flags :extra, :x
|
24
|
+
end
|
25
|
+
RUBY
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
Then %r{^external completions are ready to be installed for applications: (.*)$} do |app_list|
|
31
|
+
in_home_folder do
|
32
|
+
contents = File.read(".tabtab.bash")
|
33
|
+
app_list.split(/,\s*/).each do |app|
|
34
|
+
contents.should =~ /complete -o default -C 'tabtab --external' #{app}/
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
Then %r{^gem completions are ready to be installed for applications (.*) in gem (.*)$} do |app_list, gem_name|
|
40
|
+
in_home_folder do
|
41
|
+
contents = File.read(".tabtab.bash")
|
42
|
+
app_list.split(/,\s*/).each do |app|
|
43
|
+
contents.should =~ /complete -o default -C 'tabtab --gem #{gem_name}' #{app}/
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
Then %r{^gem completions are ready to be installed for application (.*) in gem (.*) in file (.*)$} do |app_name, gem_name, path|
|
49
|
+
in_home_folder do
|
50
|
+
contents = File.read(".tabtab.bash")
|
51
|
+
contents.should =~ %r{complete -o default -C 'tabtab --gem #{gem_name}/#{path}' #{app_name}}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
Then %r{^file completions are ready to be installed for applications (.*) in file (.*)$} do |app_list, file_name|
|
56
|
+
in_home_folder do
|
57
|
+
contents = File.read(".tabtab.bash")
|
58
|
+
app_list.split(/,\s*/).each do |app|
|
59
|
+
contents.should =~ /complete -o default -C 'tabtab --file #{file_name}' #{app}/
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
@@ -0,0 +1,211 @@
|
|
1
|
+
def in_project_folder(&block)
|
2
|
+
project_folder = @active_project_folder || @tmp_root
|
3
|
+
FileUtils.chdir(project_folder, &block)
|
4
|
+
end
|
5
|
+
|
6
|
+
def in_home_folder(&block)
|
7
|
+
FileUtils.chdir(@home_path, &block)
|
8
|
+
end
|
9
|
+
|
10
|
+
Given %r{^a safe folder} do
|
11
|
+
unless @have_created_safe_folder
|
12
|
+
FileUtils.rm_rf @tmp_root = File.dirname(__FILE__) + "/../../tmp"
|
13
|
+
FileUtils.mkdir_p @tmp_root
|
14
|
+
FileUtils.mkdir_p @home_path = File.expand_path(File.join(@tmp_root, "home"))
|
15
|
+
@lib_path = File.expand_path(File.dirname(__FILE__) + '/../../lib')
|
16
|
+
Given "env variable $HOME set to '#{@home_path}'"
|
17
|
+
@have_created_safe_folder = true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
Given %r{^this project is active project folder} do
|
22
|
+
Given "a safe folder"
|
23
|
+
@active_project_folder = File.expand_path(File.dirname(__FILE__) + "/../..")
|
24
|
+
end
|
25
|
+
|
26
|
+
Given %r{^env variable \$([\w_]+) set to '(.*)'} do |env_var, value|
|
27
|
+
ENV[env_var] = value
|
28
|
+
end
|
29
|
+
|
30
|
+
def force_local_lib_override(project_name = @project_name)
|
31
|
+
rakefile = File.read(File.join(project_name, 'Rakefile'))
|
32
|
+
File.open(File.join(project_name, 'Rakefile'), "w+") do |f|
|
33
|
+
f << "$:.unshift('#{@lib_path}')\n"
|
34
|
+
f << rakefile
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def setup_active_project_folder project_name
|
39
|
+
@active_project_folder = File.join(@tmp_root, project_name)
|
40
|
+
@project_name = project_name
|
41
|
+
end
|
42
|
+
|
43
|
+
Given %r{'(.*)' folder is deleted} do |folder|
|
44
|
+
in_project_folder do
|
45
|
+
FileUtils.rm_rf folder
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
When %r{^'(.*)' generator is invoked with arguments '(.*)'$} do |generator, arguments|
|
50
|
+
FileUtils.chdir(@active_project_folder) do
|
51
|
+
if Object.const_defined?("APP_ROOT")
|
52
|
+
APP_ROOT.replace(FileUtils.pwd)
|
53
|
+
else
|
54
|
+
APP_ROOT = FileUtils.pwd
|
55
|
+
end
|
56
|
+
run_generator(generator, arguments.split(' '), SOURCES)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
When %r{run project executable '(.*)' with arguments '(.*)'} do |executable, arguments|
|
61
|
+
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
62
|
+
in_project_folder do
|
63
|
+
system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
When %r{run local executable '(.*)' with arguments '(.*)'} do |executable, arguments|
|
68
|
+
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
69
|
+
@stderr = File.expand_path(File.join(@tmp_root, "executable.err"))
|
70
|
+
bin_executable = File.expand_path("bin/#{executable}")
|
71
|
+
in_project_folder do
|
72
|
+
system "ruby #{bin_executable} #{arguments} > #{@stdout} 2> #{@stderr}"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
When %r{^task 'rake (.*)' is invoked$} do |task|
|
77
|
+
@stdout = File.expand_path(File.join(@tmp_root, "tests.out"))
|
78
|
+
in_project_folder do
|
79
|
+
system "rake #{task} --trace > #{@stdout} 2> #{@stdout}"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
Then %r{^project folder '(.*)' is created} do |folder|
|
84
|
+
in_project_folder do
|
85
|
+
File.should be_exists(folder)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
Then %r{^home folder '(.*)' is created} do |folder|
|
90
|
+
in_home_folder do
|
91
|
+
File.should be_exists(folder)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
Then %r{^home file '(.*)' (is|is not) created} do |file, is|
|
96
|
+
in_home_folder do
|
97
|
+
if is == 'is'
|
98
|
+
File.should be_exists(file)
|
99
|
+
else
|
100
|
+
File.should_not be_exists(file)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
Then %r{^project file with name matching '(.*)' is created} do |pattern|
|
106
|
+
in_project_folder do
|
107
|
+
Dir[pattern].should_not be_empty
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
Then %r{^home file with name matching '(.*)' is created} do |pattern|
|
112
|
+
in_home_folder do
|
113
|
+
Dir[pattern].should_not be_empty
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
Then %r{gem file '(.*)' and generated file '(.*)' should be the same} do |gem_file, project_file|
|
118
|
+
File.exists?(gem_file).should be_true
|
119
|
+
File.exists?(project_file).should be_true
|
120
|
+
gem_file_contents = File.read(File.dirname(__FILE__) + "/../../#{gem_file}")
|
121
|
+
project_file_contents = File.read(File.join(@active_project_folder, project_file))
|
122
|
+
project_file_contents.should == gem_file_contents
|
123
|
+
end
|
124
|
+
|
125
|
+
Then %r{^output same as contents of '(.*)'$} do |file|
|
126
|
+
expected_output = File.read(File.join(File.dirname(__FILE__) + "/../expected_outputs", file))
|
127
|
+
actual_output = File.read(File.dirname(__FILE__) + "/../../tmp/#{@stdout}")
|
128
|
+
actual_output.should == expected_output
|
129
|
+
end
|
130
|
+
|
131
|
+
Then %r{^(does|does not) invoke generator '(.*)'$} do |does_invoke, generator|
|
132
|
+
actual_output = File.read(File.dirname(__FILE__) + "/../../tmp/#{@stdout}")
|
133
|
+
does_invoke == "does" ?
|
134
|
+
actual_output.should(match(/dependency\s+#{generator}/)) :
|
135
|
+
actual_output.should_not(match(/dependency\s+#{generator}/))
|
136
|
+
end
|
137
|
+
|
138
|
+
Then %r{help options '(.*)' and '(.*)' are displayed} do |opt1, opt2|
|
139
|
+
actual_output = File.read(@stdout)
|
140
|
+
actual_output.should match(/#{opt1}/)
|
141
|
+
actual_output.should match(/#{opt2}/)
|
142
|
+
end
|
143
|
+
|
144
|
+
Then %r{^output (does|does not) match \/(.*)\/} do |does, regex|
|
145
|
+
actual_output = File.read(@stdout)
|
146
|
+
(does == 'does') ?
|
147
|
+
actual_output.should(match(/#{regex}/)) :
|
148
|
+
actual_output.should_not(match(/#{regex}/))
|
149
|
+
end
|
150
|
+
|
151
|
+
Then %r{^contents of file '(.*)' (does|does not) match \/(.*)\/} do |file, does, regex|
|
152
|
+
in_project_folder do
|
153
|
+
actual_output = File.read(file)
|
154
|
+
(does == 'does') ?
|
155
|
+
actual_output.should(match(/#{regex}/)) :
|
156
|
+
actual_output.should_not(match(/#{regex}/))
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
Then %r{^contents of home file '(.*)' (does|does not) match \/(.*)\/} do |file, does, regex|
|
161
|
+
in_home_folder do
|
162
|
+
actual_output = File.read(file)
|
163
|
+
(does == 'does') ?
|
164
|
+
actual_output.should(match(/#{regex}/)) :
|
165
|
+
actual_output.should_not(match(/#{regex}/))
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
Then %r{^all (\d+) tests pass} do |expected_test_count|
|
170
|
+
expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors}
|
171
|
+
actual_output = File.read(@stdout)
|
172
|
+
actual_output.should match(expected)
|
173
|
+
end
|
174
|
+
|
175
|
+
Then %r{^all (\d+) examples pass} do |expected_test_count|
|
176
|
+
expected = %r{^#{expected_test_count} examples?, 0 failures}
|
177
|
+
actual_output = File.read(@stdout)
|
178
|
+
actual_output.should match(expected)
|
179
|
+
end
|
180
|
+
|
181
|
+
Then %r{^yaml file '(.*)' contains (\{.*\})} do |file, yaml|
|
182
|
+
in_project_folder do
|
183
|
+
yaml = eval yaml
|
184
|
+
YAML.load(File.read(file)).should == yaml
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
Then %r{^Rakefile can display tasks successfully} do
|
189
|
+
@stdout = File.expand_path(File.join(@tmp_root, "rakefile.out"))
|
190
|
+
FileUtils.chdir(@active_project_folder) do
|
191
|
+
system "rake -T > #{@stdout} 2> #{@stdout}"
|
192
|
+
end
|
193
|
+
actual_output = File.read(@stdout)
|
194
|
+
actual_output.should match(/^rake\s+\w+\s+#\s.*/)
|
195
|
+
end
|
196
|
+
|
197
|
+
Then %r{^task 'rake (.*)' is executed successfully} do |task|
|
198
|
+
@stdout.should_not be_nil
|
199
|
+
actual_output = File.read(@stdout)
|
200
|
+
actual_output.should_not match(/^Don't know how to build task '#{task}'/)
|
201
|
+
actual_output.should_not match(/Error/i)
|
202
|
+
end
|
203
|
+
|
204
|
+
Then %r{^gem spec key '(.*)' contains \/(.*)\/} do |key, regex|
|
205
|
+
in_project_folder do
|
206
|
+
gem_file = Dir["pkg/*.gem"].first
|
207
|
+
gem_spec = Gem::Specification.from_yaml(`gem spec #{gem_file}`)
|
208
|
+
spec_value = gem_spec.send(key.to_sym)
|
209
|
+
spec_value.to_s.should match(/#{regex}/)
|
210
|
+
end
|
211
|
+
end
|