methadone-rehab 1.9.2
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.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +11 -0
- data/CHANGES.md +66 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +201 -0
- data/README.rdoc +179 -0
- data/Rakefile +98 -0
- data/TODO.md +3 -0
- data/bin/methadone +157 -0
- data/features/bootstrap.feature +169 -0
- data/features/license.feature +43 -0
- data/features/multilevel_commands.feature +125 -0
- data/features/readme.feature +26 -0
- data/features/rspec_support.feature +27 -0
- data/features/step_definitions/bootstrap_steps.rb +47 -0
- data/features/step_definitions/license_steps.rb +30 -0
- data/features/step_definitions/readme_steps.rb +26 -0
- data/features/step_definitions/version_steps.rb +4 -0
- data/features/support/env.rb +26 -0
- data/features/version.feature +17 -0
- data/lib/methadone.rb +15 -0
- data/lib/methadone/argv_parser.rb +50 -0
- data/lib/methadone/cli.rb +124 -0
- data/lib/methadone/cli_logger.rb +133 -0
- data/lib/methadone/cli_logging.rb +138 -0
- data/lib/methadone/cucumber.rb +174 -0
- data/lib/methadone/error.rb +32 -0
- data/lib/methadone/execution_strategy/base.rb +34 -0
- data/lib/methadone/execution_strategy/jvm.rb +37 -0
- data/lib/methadone/execution_strategy/mri.rb +16 -0
- data/lib/methadone/execution_strategy/open_3.rb +16 -0
- data/lib/methadone/execution_strategy/open_4.rb +22 -0
- data/lib/methadone/execution_strategy/rbx_open_4.rb +12 -0
- data/lib/methadone/exit_now.rb +40 -0
- data/lib/methadone/main.rb +1039 -0
- data/lib/methadone/process_status.rb +45 -0
- data/lib/methadone/sh.rb +223 -0
- data/lib/methadone/version.rb +3 -0
- data/methadone-rehab.gemspec +32 -0
- data/templates/full/.gitignore.erb +4 -0
- data/templates/full/README.rdoc.erb +25 -0
- data/templates/full/Rakefile.erb +74 -0
- data/templates/full/_license_head.txt.erb +2 -0
- data/templates/full/apache_LICENSE.txt.erb +203 -0
- data/templates/full/bin/executable.erb +47 -0
- data/templates/full/custom_LICENSE.txt.erb +0 -0
- data/templates/full/features/executable.feature.erb +13 -0
- data/templates/full/features/step_definitions/executable_steps.rb.erb +1 -0
- data/templates/full/features/support/env.rb.erb +16 -0
- data/templates/full/gplv2_LICENSE.txt.erb +14 -0
- data/templates/full/gplv3_LICENSE.txt.erb +15 -0
- data/templates/full/mit_LICENSE.txt.erb +7 -0
- data/templates/multicommand/bin/executable.erb +52 -0
- data/templates/multicommand/lib/command.rb.erb +40 -0
- data/templates/multicommand/lib/commands.rb.erb +7 -0
- data/templates/rspec/spec/something_spec.rb.erb +5 -0
- data/templates/test_unit/test/tc_something.rb.erb +7 -0
- data/test/base_test.rb +20 -0
- data/test/command_for_tests.sh +7 -0
- data/test/execution_strategy/test_base.rb +24 -0
- data/test/execution_strategy/test_jvm.rb +77 -0
- data/test/execution_strategy/test_mri.rb +32 -0
- data/test/execution_strategy/test_open_3.rb +70 -0
- data/test/execution_strategy/test_open_4.rb +86 -0
- data/test/execution_strategy/test_rbx_open_4.rb +25 -0
- data/test/test_cli_logger.rb +219 -0
- data/test/test_cli_logging.rb +243 -0
- data/test/test_exit_now.rb +37 -0
- data/test/test_main.rb +1213 -0
- data/test/test_multi.rb +405 -0
- data/test/test_sh.rb +404 -0
- metadata +321 -0
data/Rakefile
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
require 'sdoc'
|
|
2
|
+
require 'bundler'
|
|
3
|
+
require 'rake/clean'
|
|
4
|
+
require 'rake/testtask'
|
|
5
|
+
require 'cucumber'
|
|
6
|
+
require 'cucumber/rake/task'
|
|
7
|
+
|
|
8
|
+
include Rake::DSL
|
|
9
|
+
|
|
10
|
+
Bundler::GemHelper.install_tasks
|
|
11
|
+
|
|
12
|
+
desc 'run tests'
|
|
13
|
+
Rake::TestTask.new do |t|
|
|
14
|
+
t.libs << "lib"
|
|
15
|
+
t.libs << "test"
|
|
16
|
+
t.ruby_opts << "-rrubygems"
|
|
17
|
+
t.test_files = FileList['test/test_*.rb'] + FileList['test/execution_strategy/test_*.rb']
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
desc 'build rdoc'
|
|
21
|
+
task :rdoc => [:build_rdoc, :hack_css]
|
|
22
|
+
RDoc::Task.new(:build_rdoc) do |rd|
|
|
23
|
+
rd.main = "README.rdoc"
|
|
24
|
+
rd.options << '-f' << 'sdoc'
|
|
25
|
+
rd.template = 'direct'
|
|
26
|
+
rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
|
|
27
|
+
rd.title = 'Methadone - Power Up your Command Line Apps'
|
|
28
|
+
end
|
|
29
|
+
CLOBBER << 'html'
|
|
30
|
+
|
|
31
|
+
FONT_FIX = {
|
|
32
|
+
"0.82em" => "16px",
|
|
33
|
+
"0.833em" => "16px",
|
|
34
|
+
"0.85em" => "16px",
|
|
35
|
+
"1.15em" => "20px",
|
|
36
|
+
"1.1em" => "20px",
|
|
37
|
+
"1.2em" => "20px",
|
|
38
|
+
"1.4em" => "24px",
|
|
39
|
+
"1.5em" => "24px",
|
|
40
|
+
"1.6em" => "32px",
|
|
41
|
+
"1em" => "16px",
|
|
42
|
+
"2.1em" => "38px",
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
task :hack_css do
|
|
47
|
+
maincss = File.open('html/css/main.css').readlines
|
|
48
|
+
File.open('html/css/main.css','w') do |file|
|
|
49
|
+
file.puts '@import url(https://fonts.googleapis.com/css?family=Lato:300italic,700italic,300,700);'
|
|
50
|
+
maincss.each do |line|
|
|
51
|
+
if line.strip == 'font-family: "Helvetica Neue", Arial, sans-serif;'
|
|
52
|
+
file.puts 'font-family: Lato, "Helvetica Neue", Arial, sans-serif;'
|
|
53
|
+
elsif line.strip == 'font-family: monospace;'
|
|
54
|
+
file.puts 'font-family: Monaco, monospace;'
|
|
55
|
+
elsif line =~ /^pre\s*$/
|
|
56
|
+
file.puts "pre {
|
|
57
|
+
font-family: Monaco, monospace;
|
|
58
|
+
margin-bottom: 1em;
|
|
59
|
+
}
|
|
60
|
+
pre.original"
|
|
61
|
+
elsif line =~ /^\s*font-size:\s*(.*)\s*;/
|
|
62
|
+
if FONT_FIX[$1]
|
|
63
|
+
file.puts "font-size: #{FONT_FIX[$1]};"
|
|
64
|
+
else
|
|
65
|
+
file.puts line.chomp
|
|
66
|
+
end
|
|
67
|
+
else
|
|
68
|
+
file.puts line.chomp
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
if RUBY_PLATFORM == 'java'
|
|
74
|
+
task :features do
|
|
75
|
+
puts "Aruba doesn't work on JRuby; cannot run features"
|
|
76
|
+
end
|
|
77
|
+
task 'features:wip' => :features
|
|
78
|
+
else
|
|
79
|
+
CUKE_RESULTS = 'results.html'
|
|
80
|
+
CLEAN << CUKE_RESULTS
|
|
81
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
|
82
|
+
tag_opts = ' --tags ~@pending'
|
|
83
|
+
tag_opts = " --tags #{ENV['TAGS']}" if ENV['TAGS']
|
|
84
|
+
t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty -x -s#{tag_opts}"
|
|
85
|
+
t.fork = false
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
Cucumber::Rake::Task.new('features:wip') do |t|
|
|
89
|
+
tag_opts = ' --tags ~@pending'
|
|
90
|
+
tag_opts = ' --tags @wip'
|
|
91
|
+
t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty -x -s#{tag_opts}"
|
|
92
|
+
t.fork = false
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
CLEAN << "coverage"
|
|
97
|
+
CLOBBER << FileList['**/*.rbc']
|
|
98
|
+
task :default => [:test, :features]
|
data/TODO.md
ADDED
data/bin/methadone
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
require 'optparse'
|
|
5
|
+
require 'methadone'
|
|
6
|
+
require 'methadone/cli'
|
|
7
|
+
|
|
8
|
+
include FileUtils
|
|
9
|
+
include Methadone::Main
|
|
10
|
+
include Methadone::CLILogging
|
|
11
|
+
include Methadone::CLI
|
|
12
|
+
include Methadone::SH
|
|
13
|
+
|
|
14
|
+
main do |app_name|
|
|
15
|
+
check_and_prepare_basedir!(app_name,options[:force])
|
|
16
|
+
using_readme = options[:readme]
|
|
17
|
+
|
|
18
|
+
gemname = File.basename(app_name)
|
|
19
|
+
module_name = gemname.split(/-/).map(&:capitalize).collect{ |segment| segment.split(/_/).map(&:capitalize).join('') }.join('::')
|
|
20
|
+
|
|
21
|
+
debug "Creating project for gem #{gemname}"
|
|
22
|
+
|
|
23
|
+
chdir File.dirname(app_name)
|
|
24
|
+
|
|
25
|
+
# Create the basic files for a gem via bundler:
|
|
26
|
+
# Gemfile
|
|
27
|
+
# Rakefile
|
|
28
|
+
# LICENSE.txt
|
|
29
|
+
# README.md
|
|
30
|
+
# .gitignore
|
|
31
|
+
# <gemname>.gemspec
|
|
32
|
+
# lib/<gemname>.rb
|
|
33
|
+
# lib/<gemname>/version.rb
|
|
34
|
+
require_file = nil
|
|
35
|
+
sh! "bundle gem #{gemname} --no-color" do |stdout|
|
|
36
|
+
require_file = stdout.split(/\n/).select { |file|
|
|
37
|
+
file =~ /\.rb$/ && file !~ /version.rb$/
|
|
38
|
+
}.first
|
|
39
|
+
end
|
|
40
|
+
require_file = gemname if require_file.nil?
|
|
41
|
+
require_file.gsub!(/^.*lib\//,'')
|
|
42
|
+
|
|
43
|
+
add_library_to_load_path = options[:add_lib] || false
|
|
44
|
+
|
|
45
|
+
chdir gemname
|
|
46
|
+
|
|
47
|
+
template_dirs_in(:full).each { |dir| mkdir_p dir }
|
|
48
|
+
|
|
49
|
+
commands = options[:commands]
|
|
50
|
+
multi = !commands.nil?
|
|
51
|
+
if multi
|
|
52
|
+
mkdir_p "lib/#{gemname}/commands"
|
|
53
|
+
copy_file 'lib/commands.rb', :as => "#{gemname}/commands.rb", :from => :multicommand, :binding => binding
|
|
54
|
+
commands.each do |cmd|
|
|
55
|
+
copy_file 'lib/command.rb', :as => "#{gemname}/commands/#{normalize_command(cmd)}.rb", :from => :multicommand, :binding => binding
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
rspec = options[:rspec]
|
|
60
|
+
|
|
61
|
+
["Rakefile", ".gitignore", "features/support/env.rb"].each do |file|
|
|
62
|
+
copy_file file, :binding => binding
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
if rspec
|
|
66
|
+
template_dirs_in(:rspec).each { |dir| mkdir_p dir }
|
|
67
|
+
copy_file "spec/something_spec.rb", :from => :rspec, :binding => binding
|
|
68
|
+
else
|
|
69
|
+
template_dirs_in(:test_unit).each { |dir| mkdir_p dir }
|
|
70
|
+
copy_file "test/tc_something.rb", :from => :test_unit, :binding => binding
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
gemspec = "#{gemname}.gemspec"
|
|
74
|
+
gem_variable = File.open(gemspec) { |x| x.read }.match(/(\w+)\.executables/)[1]
|
|
75
|
+
|
|
76
|
+
license = options[:license]
|
|
77
|
+
warn "warning: your app has no license" unless license
|
|
78
|
+
license = nil if license == 'NONE'
|
|
79
|
+
if license
|
|
80
|
+
copy_file "#{options[:license]}_LICENSE.txt", :as => "LICENSE.txt"
|
|
81
|
+
else
|
|
82
|
+
#Remove the MIT license generated by `bundle gem`
|
|
83
|
+
debug "Making sure no LICENSE.txt file exists at the root of the repo"
|
|
84
|
+
FileUtils.rm_f "LICENSE.txt"
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
#Ensure the gemspec file mentions the correct license
|
|
88
|
+
gemspec_content = File.read(gemspec)
|
|
89
|
+
if gemspec_content =~ /(^\s*#{gem_variable}\.license\s*=\s*).*/
|
|
90
|
+
gemspec_content.gsub!(/(^\s*#{gem_variable}\.license\s*=\s*).*/,"\\1#{license.to_s.inspect}")
|
|
91
|
+
else
|
|
92
|
+
gemspec_content.gsub!(/(^\s*#{gem_variable}\.name\s*=\s*.*)/,"\\1\n #{gem_variable}.license=#{license.to_s.inspect}")
|
|
93
|
+
end
|
|
94
|
+
File.open(gemspec,'w') {|f| f.write gemspec_content }
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
# TODO: bundle gem creates README.md regardless of using_readme setting.
|
|
98
|
+
copy_file "README.rdoc", :binding => binding if using_readme
|
|
99
|
+
|
|
100
|
+
copy_file "features/executable.feature", :as => "#{gemname}.feature", :binding => binding
|
|
101
|
+
copy_file "features/step_definitions/executable_steps.rb", :as => "#{gemname}_steps.rb"
|
|
102
|
+
copy_file "bin/executable", :as => gemname, :executable => true, :binding => binding, :from => (multi ? :multicommand : :full)
|
|
103
|
+
|
|
104
|
+
add_to_file gemspec, [
|
|
105
|
+
" #{gem_variable}.add_development_dependency('rdoc')",
|
|
106
|
+
" #{gem_variable}.add_development_dependency('aruba')",
|
|
107
|
+
" #{gem_variable}.add_development_dependency('rake')",
|
|
108
|
+
" #{gem_variable}.add_dependency('methadone-rehab', '~> #{Methadone::VERSION}')",
|
|
109
|
+
], :before => /^end\s*$/
|
|
110
|
+
ruby_major,ruby_minor,ruby_patch = RUBY_VERSION.split(/\./).map(&:to_i)
|
|
111
|
+
|
|
112
|
+
if ruby_major >= 2 && ruby_minor >= 2
|
|
113
|
+
add_to_file gemspec, [
|
|
114
|
+
" #{gem_variable}.add_development_dependency('test-unit')",
|
|
115
|
+
], :before => /^end\s*$/
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
if rspec
|
|
119
|
+
add_to_file gemspec, [
|
|
120
|
+
" #{gem_variable}.add_development_dependency('rspec', '~> 3')",
|
|
121
|
+
], :before => /^end\s*$/
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
sh! %q(git add --all .)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
options[:readme] = true
|
|
128
|
+
|
|
129
|
+
description "Kick the bash habit by bootstrapping your Ruby command-line apps"
|
|
130
|
+
|
|
131
|
+
on("--force","Overwrite files if they exist")
|
|
132
|
+
on("--[no-]readme","[Do not ]produce a README file")
|
|
133
|
+
on("--rspec", "Generate RSpec unit tests instead of Test::Unit")
|
|
134
|
+
on("--add-lib", "Add lib to the load path") do
|
|
135
|
+
options[:add_lib] = true
|
|
136
|
+
end
|
|
137
|
+
on "-c cmd1,cmd2,cmdN", "--commands", Array, "Generate framework for a cli app that provides the following commands" do |commands|
|
|
138
|
+
options[:commands] = commands
|
|
139
|
+
unless options[:commands].grep(/^-/).empty?
|
|
140
|
+
puts "Cannot have commands that begin with a '-'"
|
|
141
|
+
exit 65 # Data format error
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
licenses = %w(mit apache gplv2 gplv3 custom NONE)
|
|
146
|
+
on("-l LICENSE","--license",licenses,"Specify the license for your project",'(' + licenses.join('|') + ')')
|
|
147
|
+
|
|
148
|
+
use_log_level_option
|
|
149
|
+
|
|
150
|
+
leak_exceptions true
|
|
151
|
+
|
|
152
|
+
arg :app_name, :required, "Name of your app, which is used for the gem name and executable name"
|
|
153
|
+
|
|
154
|
+
version Methadone::VERSION, :compact => true
|
|
155
|
+
|
|
156
|
+
go!
|
|
157
|
+
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
Feature: Bootstrap a new command-line app
|
|
2
|
+
As an awesome developer who wants to make a command-line app
|
|
3
|
+
I should be able to use methadone to bootstrap it
|
|
4
|
+
And get all kinds of cool things
|
|
5
|
+
|
|
6
|
+
Background:
|
|
7
|
+
Given the directory "tmp/newgem" does not exist
|
|
8
|
+
And the directory "tmp/new-gem" does not exist
|
|
9
|
+
|
|
10
|
+
Scenario: Bootstrap a new app from scratch
|
|
11
|
+
When I successfully run `methadone tmp/newgem`
|
|
12
|
+
Then the following directories should exist:
|
|
13
|
+
|tmp/newgem |
|
|
14
|
+
|tmp/newgem/bin |
|
|
15
|
+
|tmp/newgem/lib |
|
|
16
|
+
|tmp/newgem/lib/newgem |
|
|
17
|
+
|tmp/newgem/test |
|
|
18
|
+
|tmp/newgem/features |
|
|
19
|
+
|tmp/newgem/features/support |
|
|
20
|
+
|tmp/newgem/features/step_definitions |
|
|
21
|
+
Then the following directories should not exist:
|
|
22
|
+
|tmp/newgem/spec |
|
|
23
|
+
And the following files should exist:
|
|
24
|
+
|tmp/newgem/newgem.gemspec |
|
|
25
|
+
|tmp/newgem/Rakefile |
|
|
26
|
+
|tmp/newgem/.gitignore |
|
|
27
|
+
|tmp/newgem/Gemfile |
|
|
28
|
+
|tmp/newgem/bin/newgem |
|
|
29
|
+
|tmp/newgem/features/newgem.feature |
|
|
30
|
+
|tmp/newgem/features/support/env.rb |
|
|
31
|
+
|tmp/newgem/features/step_definitions/newgem_steps.rb |
|
|
32
|
+
|tmp/newgem/test/tc_something.rb |
|
|
33
|
+
And the file "tmp/newgem/.gitignore" should match /results.html/
|
|
34
|
+
And the file "tmp/newgem/.gitignore" should match /html/
|
|
35
|
+
And the file "tmp/newgem/.gitignore" should match /pkg/
|
|
36
|
+
And the file "tmp/newgem/.gitignore" should match /.DS_Store/
|
|
37
|
+
And the file "tmp/newgem/newgem.gemspec" should match /add_development_dependency\('aruba'/
|
|
38
|
+
And the file "tmp/newgem/newgem.gemspec" should match /add_development_dependency\('rdoc'/
|
|
39
|
+
And the file "tmp/newgem/newgem.gemspec" should match /add_development_dependency\('rake'/
|
|
40
|
+
And the file "tmp/newgem/newgem.gemspec" should match /add_dependency\('methadone-rehab'/
|
|
41
|
+
And the file "tmp/newgem/newgem.gemspec" should include "test-unit" if needed
|
|
42
|
+
And the file "tmp/newgem/newgem.gemspec" should use the same block variable throughout
|
|
43
|
+
Given I cd to "tmp/newgem"
|
|
44
|
+
And my app's name is "newgem"
|
|
45
|
+
When I successfully run `bin/newgem --help` with "lib" in the library path
|
|
46
|
+
Then the banner should be present
|
|
47
|
+
And the banner should document that this app takes options
|
|
48
|
+
And the following options should be documented:
|
|
49
|
+
|--version|
|
|
50
|
+
|--help|
|
|
51
|
+
|--log-level|
|
|
52
|
+
And the banner should document that this app takes no arguments
|
|
53
|
+
When I successfully run `rake -T -I../../lib`
|
|
54
|
+
Then the output should match /rake clean/
|
|
55
|
+
And the output should match /rake clobber/
|
|
56
|
+
And the output should match /rake clobber_rdoc/
|
|
57
|
+
And the output should match /rake features/
|
|
58
|
+
And the output should match /rake rdoc/
|
|
59
|
+
And the output should match /rake release/
|
|
60
|
+
And the output should match /rake rerdoc/
|
|
61
|
+
And the output should match /rake test/
|
|
62
|
+
And the output should match /rake install/
|
|
63
|
+
And the output should match /rake build/
|
|
64
|
+
When I run `rake -I../../../../lib`
|
|
65
|
+
Then the exit status should be 0
|
|
66
|
+
And the output should match /1 tests, 1 assertions, 0 failures, 0 errors/
|
|
67
|
+
And the output should contain:
|
|
68
|
+
"""
|
|
69
|
+
1 scenario (1 passed)
|
|
70
|
+
6 steps (6 passed)
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
Scenario Outline: Bootstrap a new app with a dash is OK
|
|
74
|
+
Given I successfully run `methadone tmp/new-gem`
|
|
75
|
+
And I cd to "tmp/new-gem"
|
|
76
|
+
And my app's name is "new-gem"
|
|
77
|
+
When I successfully run `bin/new-gem <help>` with "lib" in the library path
|
|
78
|
+
Then the banner should be present
|
|
79
|
+
And the banner should document that this app takes options
|
|
80
|
+
And the following options should be documented:
|
|
81
|
+
|--version|
|
|
82
|
+
|--log-level|
|
|
83
|
+
And the banner should document that this app takes no arguments
|
|
84
|
+
When I run `rake -I../../../../lib`
|
|
85
|
+
Then the exit status should be 0
|
|
86
|
+
And the output should match /1 tests, 1 assertions, 0 failures, 0 errors/
|
|
87
|
+
And the output should contain:
|
|
88
|
+
"""
|
|
89
|
+
1 scenario (1 passed)
|
|
90
|
+
6 steps (6 passed)
|
|
91
|
+
"""
|
|
92
|
+
Examples:
|
|
93
|
+
| help |
|
|
94
|
+
| -h |
|
|
95
|
+
| --help |
|
|
96
|
+
| --version |
|
|
97
|
+
|
|
98
|
+
Scenario: Version flag can be used to only show the app version
|
|
99
|
+
Given I successfully run `methadone tmp/new-gem`
|
|
100
|
+
And "bin/new-gem" has configured version to show only the version and not help
|
|
101
|
+
And I cd to "tmp/new-gem"
|
|
102
|
+
And my app's name is "new-gem"
|
|
103
|
+
When I successfully run `bin/new-gem --version` with "lib" in the library path
|
|
104
|
+
Then the output should match /new-gem version 0/
|
|
105
|
+
|
|
106
|
+
Scenario: Version flag can be used to only show the app version with a custom format
|
|
107
|
+
Given I successfully run `methadone tmp/new-gem`
|
|
108
|
+
And "bin/new-gem" has configured version to show only the version with a custom format and not help
|
|
109
|
+
And I cd to "tmp/new-gem"
|
|
110
|
+
And my app's name is "new-gem"
|
|
111
|
+
When I successfully run `bin/new-gem --version` with "lib" in the library path
|
|
112
|
+
Then the output should match /new-gem V0/
|
|
113
|
+
|
|
114
|
+
Scenario: Won't squash an existing dir
|
|
115
|
+
When I successfully run `methadone tmp/newgem`
|
|
116
|
+
And I run `methadone tmp/newgem`
|
|
117
|
+
Then the exit status should not be 0
|
|
118
|
+
And the stderr should contain:
|
|
119
|
+
"""
|
|
120
|
+
error: tmp/newgem exists, use --force to override
|
|
121
|
+
"""
|
|
122
|
+
|
|
123
|
+
Scenario: WILL squash an existing dir if we use --force
|
|
124
|
+
When I successfully run `methadone tmp/newgem`
|
|
125
|
+
And I run `methadone --force tmp/newgem`
|
|
126
|
+
Then the exit status should be 0
|
|
127
|
+
|
|
128
|
+
Scenario: We must supply a dirname
|
|
129
|
+
When I run `methadone`
|
|
130
|
+
Then the exit status should not be 0
|
|
131
|
+
And the stderr should match /'app_name' is required/
|
|
132
|
+
|
|
133
|
+
Scenario: We can add the lib directory to the load path
|
|
134
|
+
Given the directory "tmp/newgem2" does not exist
|
|
135
|
+
When I run `methadone --add-lib tmp/newgem2`
|
|
136
|
+
Then the exit status should be 0
|
|
137
|
+
And the file "tmp/newgem2/bin/newgem2" should match /\$LOAD_PATH\.unshift File\.expand_path\(File\.join\(File\.dirname\(__FILE__\), '\.\..lib'\)\)/
|
|
138
|
+
|
|
139
|
+
Given I cd to "tmp/newgem2"
|
|
140
|
+
And my app's name is "newgem2"
|
|
141
|
+
When I successfully run `bin/newgem2 --help`
|
|
142
|
+
Then the banner should be present
|
|
143
|
+
And the banner should document that this app takes options
|
|
144
|
+
And the following options should be documented:
|
|
145
|
+
|--version|
|
|
146
|
+
|--help|
|
|
147
|
+
|--log-level|
|
|
148
|
+
And the banner should document that this app takes no arguments
|
|
149
|
+
|
|
150
|
+
Scenario: Help is properly documented
|
|
151
|
+
When I get help for "methadone"
|
|
152
|
+
Then the exit status should be 0
|
|
153
|
+
And the following options should be documented:
|
|
154
|
+
| --force | |
|
|
155
|
+
| --readme | which is negatable |
|
|
156
|
+
| -l, --license | which is not negatable |
|
|
157
|
+
| --log-level | |
|
|
158
|
+
And the banner should be present
|
|
159
|
+
And the banner should document that this app takes options
|
|
160
|
+
And the banner should document that this app's arguments are:
|
|
161
|
+
|app_name|which is required|
|
|
162
|
+
And there should be a one line summary of what the app does
|
|
163
|
+
|
|
164
|
+
Scenario: The whole initial state of the app has been staged with git
|
|
165
|
+
Given I successfully run `methadone -l custom tmp/newgem`
|
|
166
|
+
And I cd to "tmp/newgem"
|
|
167
|
+
When I successfully run `git ls-files --others --deleted `
|
|
168
|
+
Then the output should match /\A\Z/
|
|
169
|
+
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Feature: Users should get the license included
|
|
2
|
+
As a user
|
|
3
|
+
I'd like to be able to include a license
|
|
4
|
+
So that I don't have to hunt it down for every new project
|
|
5
|
+
|
|
6
|
+
Background:
|
|
7
|
+
Given the directory "tmp/newgem" does not exist
|
|
8
|
+
|
|
9
|
+
Scenario: Use a non-stock license
|
|
10
|
+
When I successfully run `methadone -l custom tmp/newgem`
|
|
11
|
+
Then newgem's license should be an empty file
|
|
12
|
+
And the README should reference the need for a license
|
|
13
|
+
|
|
14
|
+
Scenario: We only support a few licenses
|
|
15
|
+
When I run `methadone -l foobar tmp/newgem`
|
|
16
|
+
Then the exit status should not be 0
|
|
17
|
+
And the stderr should match /invalid argument: -l foobar/
|
|
18
|
+
|
|
19
|
+
Scenario: No license specified
|
|
20
|
+
When I successfully run `methadone tmp/newgem`
|
|
21
|
+
Then the stderr should contain "warning: your app has no license"
|
|
22
|
+
And the README should not reference a license
|
|
23
|
+
And the file "tmp/newgem/LICENSE.txt" should not exist
|
|
24
|
+
|
|
25
|
+
Scenario: No license specified explicitly
|
|
26
|
+
When I successfully run `methadone -l NONE tmp/newgem`
|
|
27
|
+
Then the stderr should not contain "warning: your app has no license"
|
|
28
|
+
And the README should not reference a license
|
|
29
|
+
And the file "tmp/newgem/LICENSE.txt" should not exist
|
|
30
|
+
|
|
31
|
+
Scenario Outline: Include one of a few stock licenses
|
|
32
|
+
When I successfully run `methadone -l <license> tmp/newgem`
|
|
33
|
+
Then newgem's license should be the <license> license
|
|
34
|
+
And the README should reference this license
|
|
35
|
+
And LICENSE.txt should contain user information and program name
|
|
36
|
+
|
|
37
|
+
Examples:
|
|
38
|
+
|license|
|
|
39
|
+
|apache|
|
|
40
|
+
|mit|
|
|
41
|
+
|gplv2|
|
|
42
|
+
|gplv3|
|
|
43
|
+
|