jeweler2 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +8 -0
- data/ChangeLog.markdown +177 -0
- data/Gemfile +18 -0
- data/Gemfile.lock +47 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +217 -0
- data/Rakefile +80 -0
- data/bin/jeweler +5 -0
- data/features/generator/cucumber.feature +103 -0
- data/features/generator/directory_layout.feature +86 -0
- data/features/generator/dotdocument.feature +13 -0
- data/features/generator/env_options.feature +9 -0
- data/features/generator/gemfile.feature +71 -0
- data/features/generator/git.feature +102 -0
- data/features/generator/license.feature +20 -0
- data/features/generator/rakefile.feature +158 -0
- data/features/generator/readme.feature +12 -0
- data/features/generator/test.feature +54 -0
- data/features/generator/test_helper.feature +149 -0
- data/features/placeholder.feature +5 -0
- data/features/step_definitions/debug_steps.rb +6 -0
- data/features/step_definitions/filesystem_steps.rb +70 -0
- data/features/step_definitions/generator_steps.rb +380 -0
- data/features/step_definitions/task_steps.rb +6 -0
- data/features/support/env.rb +42 -0
- data/features/tasks/build_gem.feature +9 -0
- data/features/tasks/version.feature +31 -0
- data/features/tasks/version_bumping.feature +49 -0
- data/jeweler.gemspec +245 -0
- data/jeweler2.gemspec +233 -0
- data/lib/jeweler/commands/build_gem.rb +36 -0
- data/lib/jeweler/commands/check_dependencies.rb +66 -0
- data/lib/jeweler/commands/install_gem.rb +31 -0
- data/lib/jeweler/commands/release_gemspec.rb +82 -0
- data/lib/jeweler/commands/release_to_git.rb +59 -0
- data/lib/jeweler/commands/release_to_rubygems.rb +28 -0
- data/lib/jeweler/commands/validate_gemspec.rb +30 -0
- data/lib/jeweler/commands/version/base.rb +55 -0
- data/lib/jeweler/commands/version/bump_major.rb +13 -0
- data/lib/jeweler/commands/version/bump_minor.rb +12 -0
- data/lib/jeweler/commands/version/bump_patch.rb +14 -0
- data/lib/jeweler/commands/version/write.rb +12 -0
- data/lib/jeweler/commands/write_gemspec.rb +39 -0
- data/lib/jeweler/commands.rb +20 -0
- data/lib/jeweler/errors.rb +8 -0
- data/lib/jeweler/gemcutter_tasks.rb +8 -0
- data/lib/jeweler/gemspec_helper.rb +87 -0
- data/lib/jeweler/generator/application.rb +61 -0
- data/lib/jeweler/generator/bacon_mixin.rb +43 -0
- data/lib/jeweler/generator/github_mixin.rb +29 -0
- data/lib/jeweler/generator/micronaut_mixin.rb +41 -0
- data/lib/jeweler/generator/minitest_mixin.rb +42 -0
- data/lib/jeweler/generator/options.rb +163 -0
- data/lib/jeweler/generator/rdoc_mixin.rb +9 -0
- data/lib/jeweler/generator/riot_mixin.rb +42 -0
- data/lib/jeweler/generator/rspec_mixin.rb +42 -0
- data/lib/jeweler/generator/shindo_mixin.rb +44 -0
- data/lib/jeweler/generator/shoulda_mixin.rb +42 -0
- data/lib/jeweler/generator/testspec_mixin.rb +42 -0
- data/lib/jeweler/generator/testunit_mixin.rb +39 -0
- data/lib/jeweler/generator/yard_mixin.rb +14 -0
- data/lib/jeweler/generator.rb +295 -0
- data/lib/jeweler/rubyforge_tasks.rb +95 -0
- data/lib/jeweler/rubygems_dot_org_tasks.rb +38 -0
- data/lib/jeweler/rubygems_tasks.rb +38 -0
- data/lib/jeweler/specification.rb +110 -0
- data/lib/jeweler/tasks.rb +224 -0
- data/lib/jeweler/templates/.document +5 -0
- data/lib/jeweler/templates/.gitignore +48 -0
- data/lib/jeweler/templates/Gemfile +12 -0
- data/lib/jeweler/templates/LICENSE.txt +20 -0
- data/lib/jeweler/templates/README.rdoc +19 -0
- data/lib/jeweler/templates/Rakefile +9 -0
- data/lib/jeweler/templates/bacon/flunking.rb +7 -0
- data/lib/jeweler/templates/bacon/helper.rb +9 -0
- data/lib/jeweler/templates/bundler_setup.erb +10 -0
- data/lib/jeweler/templates/features/default.feature +9 -0
- data/lib/jeweler/templates/features/support/env.rb +10 -0
- data/lib/jeweler/templates/jeweler_tasks.erb +31 -0
- data/lib/jeweler/templates/micronaut/flunking.rb +7 -0
- data/lib/jeweler/templates/micronaut/helper.rb +18 -0
- data/lib/jeweler/templates/minitest/flunking.rb +7 -0
- data/lib/jeweler/templates/minitest/helper.rb +12 -0
- data/lib/jeweler/templates/other_tasks.erb +86 -0
- data/lib/jeweler/templates/riot/flunking.rb +11 -0
- data/lib/jeweler/templates/riot/helper.rb +4 -0
- data/lib/jeweler/templates/rspec/.rspec +1 -0
- data/lib/jeweler/templates/rspec/flunking.rb +7 -0
- data/lib/jeweler/templates/rspec/helper.rb +12 -0
- data/lib/jeweler/templates/shindo/flunking.rb +8 -0
- data/lib/jeweler/templates/shindo/helper.rb +6 -0
- data/lib/jeweler/templates/shoulda/flunking.rb +7 -0
- data/lib/jeweler/templates/shoulda/helper.rb +11 -0
- data/lib/jeweler/templates/testspec/flunking.rb +7 -0
- data/lib/jeweler/templates/testspec/helper.rb +7 -0
- data/lib/jeweler/templates/testunit/flunking.rb +7 -0
- data/lib/jeweler/templates/testunit/helper.rb +10 -0
- data/lib/jeweler/version.rb +10 -0
- data/lib/jeweler/version_helper.rb +141 -0
- data/lib/jeweler.rb +177 -0
- data/test/fixtures/bar/VERSION.yml +4 -0
- data/test/fixtures/bar/bin/foo_the_ultimate_bin +1 -0
- data/test/fixtures/bar/hey_include_me_in_gemspec +0 -0
- data/test/fixtures/bar/lib/foo_the_ultimate_lib.rb +1 -0
- data/test/fixtures/existing-project-with-version-constant/.document +5 -0
- data/test/fixtures/existing-project-with-version-constant/.gitignore +5 -0
- data/test/fixtures/existing-project-with-version-constant/LICENSE.txt +20 -0
- data/test/fixtures/existing-project-with-version-constant/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version-constant/Rakefile +85 -0
- data/test/fixtures/existing-project-with-version-constant/existing-project-with-version.gemspec +29 -0
- data/test/fixtures/existing-project-with-version-constant/lib/existing_project_with_version.rb +0 -0
- data/test/fixtures/existing-project-with-version-constant/test/existing_project_with_version_test.rb +7 -0
- data/test/fixtures/existing-project-with-version-constant/test/test_helper.rb +10 -0
- data/test/fixtures/existing-project-with-version-plaintext/.document +5 -0
- data/test/fixtures/existing-project-with-version-plaintext/.gitignore +5 -0
- data/test/fixtures/existing-project-with-version-plaintext/LICENSE.txt +20 -0
- data/test/fixtures/existing-project-with-version-plaintext/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version-plaintext/Rakefile +84 -0
- data/test/fixtures/existing-project-with-version-plaintext/VERSION +1 -0
- data/test/fixtures/existing-project-with-version-plaintext/existing-project-with-version.gemspec +29 -0
- data/test/fixtures/existing-project-with-version-plaintext/lib/existing_project_with_version.rb +0 -0
- data/test/fixtures/existing-project-with-version-plaintext/test/existing_project_with_version_test.rb +7 -0
- data/test/fixtures/existing-project-with-version-plaintext/test/test_helper.rb +10 -0
- data/test/fixtures/existing-project-with-version-yaml/.document +5 -0
- data/test/fixtures/existing-project-with-version-yaml/.gitignore +5 -0
- data/test/fixtures/existing-project-with-version-yaml/LICENSE.txt +20 -0
- data/test/fixtures/existing-project-with-version-yaml/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version-yaml/Rakefile +84 -0
- data/test/fixtures/existing-project-with-version-yaml/VERSION.yml +4 -0
- data/test/fixtures/existing-project-with-version-yaml/bin/foo_the_ultimate_bin +0 -0
- data/test/fixtures/existing-project-with-version-yaml/existing-project-with-version.gemspec +29 -0
- data/test/fixtures/existing-project-with-version-yaml/lib/existing_project_with_version.rb +0 -0
- data/test/fixtures/existing-project-with-version-yaml/test/existing_project_with_version_test.rb +7 -0
- data/test/fixtures/existing-project-with-version-yaml/test/test_helper.rb +10 -0
- data/test/geminstaller.yml +12 -0
- data/test/jeweler/commands/test_build_gem.rb +103 -0
- data/test/jeweler/commands/test_install_gem.rb +35 -0
- data/test/jeweler/commands/test_release_to_gemcutter.rb +39 -0
- data/test/jeweler/commands/test_release_to_git.rb +198 -0
- data/test/jeweler/commands/test_release_to_github.rb +390 -0
- data/test/jeweler/commands/test_validate_gemspec.rb +27 -0
- data/test/jeweler/commands/test_write_gemspec.rb +101 -0
- data/test/jeweler/commands/version/test_base.rb +32 -0
- data/test/jeweler/commands/version/test_bump_major.rb +22 -0
- data/test/jeweler/commands/version/test_bump_minor.rb +19 -0
- data/test/jeweler/commands/version/test_bump_patch.rb +20 -0
- data/test/jeweler/commands/version/test_write.rb +22 -0
- data/test/jeweler/generator/test_application.rb +120 -0
- data/test/jeweler/generator/test_options.rb +225 -0
- data/test/jeweler/test_gemspec_helper.rb +44 -0
- data/test/jeweler/test_generator.rb +141 -0
- data/test/jeweler/test_generator_initialization.rb +164 -0
- data/test/jeweler/test_generator_mixins.rb +23 -0
- data/test/jeweler/test_specification.rb +237 -0
- data/test/jeweler/test_tasks.rb +50 -0
- data/test/jeweler/test_version_helper.rb +214 -0
- data/test/shoulda_macros/jeweler_macros.rb +35 -0
- data/test/test_helper.rb +178 -0
- data/test/test_jeweler.rb +175 -0
- metadata +343 -0
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestApplication < Test::Unit::TestCase
|
4
|
+
def run_application(*arguments)
|
5
|
+
original_stdout = $stdout
|
6
|
+
original_stderr = $stderr
|
7
|
+
|
8
|
+
fake_stdout = StringIO.new
|
9
|
+
fake_stderr = StringIO.new
|
10
|
+
|
11
|
+
$stdout = fake_stdout
|
12
|
+
$stderr = fake_stderr
|
13
|
+
|
14
|
+
result = nil
|
15
|
+
begin
|
16
|
+
result = Jeweler::Generator::Application.run!(*arguments)
|
17
|
+
ensure
|
18
|
+
$stdout = original_stdout
|
19
|
+
$stderr = original_stderr
|
20
|
+
end
|
21
|
+
|
22
|
+
@stdout = fake_stdout.string
|
23
|
+
@stderr = fake_stderr.string
|
24
|
+
|
25
|
+
result
|
26
|
+
end
|
27
|
+
|
28
|
+
def stub_options(options = {})
|
29
|
+
stub(options).opts { 'Usage:' }
|
30
|
+
|
31
|
+
options
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.should_exit_with_code(code)
|
35
|
+
should "exit with code #{code}" do
|
36
|
+
assert_equal code, @result
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "when options indicate help usage" do
|
41
|
+
setup do
|
42
|
+
stub(Jeweler::Generator::Application).build_opts do
|
43
|
+
stub_options(:show_help => true)
|
44
|
+
end
|
45
|
+
|
46
|
+
stub(Jeweler::Generator).new { raise "Shouldn't have made this far"}
|
47
|
+
|
48
|
+
assert_nothing_raised do
|
49
|
+
@result = run_application("-h")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
should_exit_with_code 1
|
54
|
+
|
55
|
+
should 'should puts option usage' do
|
56
|
+
assert_match 'Usage:', @stderr
|
57
|
+
end
|
58
|
+
|
59
|
+
should 'not display anything on stdout' do
|
60
|
+
assert_equal '', @stdout.squeeze.strip
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "when options indicate an invalid argument" do
|
65
|
+
setup do
|
66
|
+
stub(Jeweler::Generator::Application).build_opts do
|
67
|
+
stub_options(:invalid_argument => '--invalid-argument')
|
68
|
+
end
|
69
|
+
|
70
|
+
stub(Jeweler::Generator).new { raise "Shouldn't have made this far"}
|
71
|
+
|
72
|
+
assert_nothing_raised do
|
73
|
+
@result = run_application("--invalid-argument")
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
should_exit_with_code 1
|
78
|
+
|
79
|
+
should 'display invalid argument' do
|
80
|
+
assert_match '--invalid-argument', @stderr
|
81
|
+
end
|
82
|
+
|
83
|
+
should 'display usage on stderr' do
|
84
|
+
assert_match 'Usage:', @stderr
|
85
|
+
end
|
86
|
+
|
87
|
+
should 'not display anything on stdout' do
|
88
|
+
assert_equal '', @stdout.squeeze.strip
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
context "when options are good" do
|
94
|
+
setup do
|
95
|
+
@generator = "generator"
|
96
|
+
stub(@generator).run
|
97
|
+
stub(Jeweler::Generator).new { @generator }
|
98
|
+
|
99
|
+
@jeweler_options = stub_options :project_name => 'zomg'
|
100
|
+
stub(Jeweler::Generator::Application).build_options do
|
101
|
+
@jeweler_options
|
102
|
+
end
|
103
|
+
|
104
|
+
assert_nothing_raised do
|
105
|
+
@result = run_application("zomg")
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
should_exit_with_code 0
|
110
|
+
|
111
|
+
should "create generator with options" do
|
112
|
+
assert_received(Jeweler::Generator) {|subject| subject.new(@jeweler_options) }
|
113
|
+
end
|
114
|
+
|
115
|
+
should "run generator" do
|
116
|
+
assert_received(@generator) {|subject| subject.run }
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
@@ -0,0 +1,225 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestOptions < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
set_default_git_config
|
7
|
+
stub_git_config valid_git_config
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.should_have_testing_framework(testing_framework)
|
11
|
+
should "use #{testing_framework} for testing" do
|
12
|
+
assert_equal testing_framework.to_sym, @options[:testing_framework]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.should_have_docmentation_framework(documentation_framework)
|
17
|
+
should "use #{documentation_framework} for documentation" do
|
18
|
+
assert_equal documentation_framework.to_sym, @options[:documentation_framework]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def setup_options(*arguments)
|
23
|
+
@options = Jeweler::Generator::Options.new(["project_name"] + arguments)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.for_options(*options)
|
27
|
+
context options.join(' ') do
|
28
|
+
setup { setup_options *options }
|
29
|
+
yield
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "default options" do
|
34
|
+
setup { setup_options }
|
35
|
+
should_have_testing_framework :shoulda
|
36
|
+
should_have_docmentation_framework :rdoc
|
37
|
+
|
38
|
+
should 'not create repository' do
|
39
|
+
assert ! @options[:create_repo]
|
40
|
+
end
|
41
|
+
|
42
|
+
should "have project name" do
|
43
|
+
assert_equal "project_name", @options[:project_name]
|
44
|
+
end
|
45
|
+
|
46
|
+
should "use github username from git config" do
|
47
|
+
assert_equal @github_user, @options[:github_username]
|
48
|
+
end
|
49
|
+
|
50
|
+
should "use github token from git config" do
|
51
|
+
assert_equal @github_token, @options[:github_token]
|
52
|
+
end
|
53
|
+
|
54
|
+
should "use user name from git config" do
|
55
|
+
assert_equal @git_name, @options[:user_name]
|
56
|
+
end
|
57
|
+
|
58
|
+
should "use user email from git config" do
|
59
|
+
assert_equal @git_email, @options[:user_email]
|
60
|
+
end
|
61
|
+
|
62
|
+
should "use bundler" do
|
63
|
+
assert @options[:use_bundler]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
for_options "--bacon" do
|
68
|
+
should_have_testing_framework :bacon
|
69
|
+
end
|
70
|
+
|
71
|
+
for_options '--micronaut' do
|
72
|
+
should_have_testing_framework :micronaut
|
73
|
+
end
|
74
|
+
|
75
|
+
for_options '--minitest' do
|
76
|
+
should_have_testing_framework :minitest
|
77
|
+
end
|
78
|
+
|
79
|
+
for_options '--rspec' do
|
80
|
+
should_have_testing_framework :rspec
|
81
|
+
end
|
82
|
+
|
83
|
+
for_options '--shoulda' do
|
84
|
+
should_have_testing_framework :shoulda
|
85
|
+
end
|
86
|
+
|
87
|
+
for_options "--testunit" do
|
88
|
+
should_have_testing_framework :testunit
|
89
|
+
end
|
90
|
+
|
91
|
+
for_options "--testspec" do
|
92
|
+
should_have_testing_framework :testspec
|
93
|
+
end
|
94
|
+
|
95
|
+
for_options '--cucumber' do
|
96
|
+
should 'enable cucumber' do
|
97
|
+
assert_equal true, @options[:use_cucumber]
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
for_options '--reek' do
|
102
|
+
should 'enable reek' do
|
103
|
+
assert_equal true, @options[:use_reek]
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
for_options '--roodi' do
|
108
|
+
should 'enable roodi' do
|
109
|
+
assert_equal true, @options[:use_roodi]
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
for_options '--create-repo' do
|
114
|
+
should 'create repository' do
|
115
|
+
assert @options[:create_repo]
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
for_options '--rdoc' do
|
120
|
+
should_have_docmentation_framework :rdoc
|
121
|
+
end
|
122
|
+
|
123
|
+
for_options '--yard' do
|
124
|
+
should_have_docmentation_framework :yard
|
125
|
+
end
|
126
|
+
|
127
|
+
for_options '--summary', 'zomg so awesome' do
|
128
|
+
should 'have summary zomg so awesome' do
|
129
|
+
assert_equal 'zomg so awesome', @options[:summary]
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
for_options '--description', 'Descriptive' do
|
134
|
+
should 'have description Descriptive' do
|
135
|
+
assert_equal 'Descriptive', @options[:description]
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
for_options '--directory', 'foo' do
|
140
|
+
should 'have directory foo' do
|
141
|
+
assert_equal 'foo', @options[:directory]
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
for_options '--help' do
|
146
|
+
should 'show help' do
|
147
|
+
assert @options[:show_help]
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
for_options '-h' do
|
152
|
+
should 'show help' do
|
153
|
+
assert @options[:show_help]
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
for_options '--zomg-invalid' do
|
158
|
+
should 'be an invalid argument' do
|
159
|
+
assert @options[:invalid_argument]
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
for_options '--user-name', 'myname' do
|
164
|
+
should "set user name" do
|
165
|
+
assert_equal 'myname', @options[:user_name]
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
for_options '--user-email', 'myname@mydomain.com' do
|
170
|
+
should "set user email" do
|
171
|
+
assert_equal 'myname@mydomain.com', @options[:user_email]
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
for_options '--homepage', 'http://zomg.com' do
|
176
|
+
should 'set hoempage' do
|
177
|
+
assert_equal 'http://zomg.com', @options[:homepage]
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
for_options '--git-remote', 'git@my-awesome-domain.com:zomg.git' do
|
182
|
+
should 'set the git remote' do
|
183
|
+
assert_equal 'git@my-awesome-domain.com:zomg.git', @options[:git_remote]
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
for_options '--github-username', 'mygithub' do
|
188
|
+
should "set github username" do
|
189
|
+
assert_equal 'mygithub', @options[:github_username]
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
for_options '--github-token', 'mygithubtoken' do
|
194
|
+
should "set github token" do
|
195
|
+
assert_equal 'mygithubtoken', @options[:github_token]
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
for_options '--bundler' do
|
200
|
+
should "use bundler" do
|
201
|
+
assert @options[:use_bundler]
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
for_options '--no-bundler' do
|
206
|
+
should "not use bundler" do
|
207
|
+
assert !@options[:use_bundler]
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
context "merging options" do
|
212
|
+
should "take options from each" do
|
213
|
+
options = Jeweler::Generator::Options.new(["--rspec"]).
|
214
|
+
merge Jeweler::Generator::Options.new(["--create-repo"])
|
215
|
+
assert_equal :rspec, options[:testing_framework]
|
216
|
+
assert options[:create_repo]
|
217
|
+
end
|
218
|
+
|
219
|
+
should "shadow options" do
|
220
|
+
options = Jeweler::Generator::Options.new(["--bacon"]).
|
221
|
+
merge Jeweler::Generator::Options.new(["--rspec"])
|
222
|
+
assert_equal :rspec, options[:testing_framework]
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestGemspecHelper < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Rake.application.instance_variable_set(:@rakefile, "Rakefile")
|
6
|
+
end
|
7
|
+
|
8
|
+
context "given a gemspec" do
|
9
|
+
setup do
|
10
|
+
@spec = build_spec
|
11
|
+
@helper = Jeweler::GemSpecHelper.new(@spec, File.dirname(__FILE__))
|
12
|
+
end
|
13
|
+
|
14
|
+
should 'have sane gemspec path' do
|
15
|
+
assert_equal "test/jeweler/#{@spec.name}.gemspec", @helper.path
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "#write" do
|
20
|
+
setup do
|
21
|
+
@spec = build_spec
|
22
|
+
@helper = Jeweler::GemSpecHelper.new(@spec, File.dirname(__FILE__))
|
23
|
+
FileUtils.rm_f(@helper.path)
|
24
|
+
|
25
|
+
@helper.write
|
26
|
+
end
|
27
|
+
|
28
|
+
teardown do
|
29
|
+
FileUtils.rm_f(@helper.path)
|
30
|
+
end
|
31
|
+
|
32
|
+
should "create gemspec file" do
|
33
|
+
assert File.exists?(@helper.path)
|
34
|
+
end
|
35
|
+
|
36
|
+
should "make valid spec" do
|
37
|
+
assert @helper.valid?
|
38
|
+
end
|
39
|
+
|
40
|
+
should "parse" do
|
41
|
+
@helper.parse
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestGenerator < Test::Unit::TestCase
|
4
|
+
def build_generator(testing_framework = :shoulda, options = {})
|
5
|
+
options = {
|
6
|
+
:project_name => 'the-perfect-gem',
|
7
|
+
:user_name => 'John Doe',
|
8
|
+
:user_email => 'john@example.com',
|
9
|
+
:github_username => 'johndoe',
|
10
|
+
:github_token => 'yyz',
|
11
|
+
:documentation_framework => :rdoc
|
12
|
+
}.merge(options)
|
13
|
+
|
14
|
+
options[:testing_framework] = testing_framework
|
15
|
+
Jeweler::Generator.new(options)
|
16
|
+
end
|
17
|
+
|
18
|
+
should "have the correct constant name" do
|
19
|
+
assert_equal "ThePerfectGem", build_generator.constant_name
|
20
|
+
end
|
21
|
+
|
22
|
+
should "have the correct file name prefix" do
|
23
|
+
assert_equal "the_perfect_gem", build_generator.file_name_prefix
|
24
|
+
end
|
25
|
+
|
26
|
+
should "have the correct require name" do
|
27
|
+
assert_equal "the-perfect-gem", build_generator.require_name
|
28
|
+
end
|
29
|
+
|
30
|
+
should "have the correct lib file name" do
|
31
|
+
assert_equal "the-perfect-gem.rb", build_generator.lib_filename
|
32
|
+
end
|
33
|
+
|
34
|
+
should "have the correct git-remote" do
|
35
|
+
assert_equal 'user@host:/path/to/repo', build_generator(:shoulda, {:git_remote => "user@host:/path/to/repo"}).git_remote
|
36
|
+
assert_equal 'git@github.com:johndoe/the-perfect-gem.git', build_generator.git_remote
|
37
|
+
end
|
38
|
+
|
39
|
+
should "extract project name from absolut path" do
|
40
|
+
assert_equal "my-project", build_generator(:shoulda, {:project_name => "/tmp/my-project"}).project_name
|
41
|
+
end
|
42
|
+
|
43
|
+
should "extract project name from relative path" do
|
44
|
+
assert_equal "my-project", build_generator(:shoulda, {:project_name => "../my-project"}).project_name
|
45
|
+
end
|
46
|
+
|
47
|
+
should "extract project name from direct path" do
|
48
|
+
assert_equal "my-project", build_generator(:shoulda, {:project_name => "my-project"}).project_name
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.should_have_generator_attribute(attribute, value)
|
52
|
+
should "have #{value} for #{attribute}" do
|
53
|
+
assert_equal value, build_generator(@framework).send(attribute)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "shoulda" do
|
58
|
+
setup { @framework = :shoulda }
|
59
|
+
should_have_generator_attribute :test_task, 'test'
|
60
|
+
should_have_generator_attribute :test_dir, 'test'
|
61
|
+
should_have_generator_attribute :default_task, 'test'
|
62
|
+
should_have_generator_attribute :feature_support_require, 'test/unit/assertions'
|
63
|
+
should_have_generator_attribute :feature_support_extend, 'Test::Unit::Assertions'
|
64
|
+
should_have_generator_attribute :test_pattern, 'test/**/test_*.rb'
|
65
|
+
should_have_generator_attribute :test_filename, 'test_the-perfect-gem.rb'
|
66
|
+
should_have_generator_attribute :test_helper_filename, 'helper.rb'
|
67
|
+
end
|
68
|
+
|
69
|
+
context "testunit" do
|
70
|
+
setup { @framework = :testunit }
|
71
|
+
should_have_generator_attribute :test_task, 'test'
|
72
|
+
should_have_generator_attribute :test_dir, 'test'
|
73
|
+
should_have_generator_attribute :default_task, 'test'
|
74
|
+
should_have_generator_attribute :feature_support_require, 'test/unit/assertions'
|
75
|
+
should_have_generator_attribute :feature_support_extend, 'Test::Unit::Assertions'
|
76
|
+
should_have_generator_attribute :test_pattern, 'test/**/test_*.rb'
|
77
|
+
should_have_generator_attribute :test_filename, 'test_the-perfect-gem.rb'
|
78
|
+
should_have_generator_attribute :test_helper_filename, 'helper.rb'
|
79
|
+
end
|
80
|
+
|
81
|
+
context "minitest" do
|
82
|
+
setup { @framework = :minitest }
|
83
|
+
should_have_generator_attribute :test_task, 'test'
|
84
|
+
should_have_generator_attribute :test_dir, 'test'
|
85
|
+
should_have_generator_attribute :default_task, 'test'
|
86
|
+
should_have_generator_attribute :feature_support_require, 'minitest/unit'
|
87
|
+
should_have_generator_attribute :feature_support_extend, 'MiniTest::Assertions'
|
88
|
+
should_have_generator_attribute :test_pattern, 'test/**/test_*.rb'
|
89
|
+
should_have_generator_attribute :test_filename, 'test_the-perfect-gem.rb'
|
90
|
+
should_have_generator_attribute :test_helper_filename, 'helper.rb'
|
91
|
+
end
|
92
|
+
|
93
|
+
context "bacon" do
|
94
|
+
setup { @framework = :bacon }
|
95
|
+
should_have_generator_attribute :test_task, 'spec'
|
96
|
+
should_have_generator_attribute :test_dir, 'spec'
|
97
|
+
should_have_generator_attribute :default_task, 'spec'
|
98
|
+
should_have_generator_attribute :feature_support_require, 'test/unit/assertions'
|
99
|
+
should_have_generator_attribute :feature_support_extend, 'Test::Unit::Assertions'
|
100
|
+
should_have_generator_attribute :test_pattern, 'spec/**/*_spec.rb'
|
101
|
+
should_have_generator_attribute :test_filename, 'the-perfect-gem_spec.rb'
|
102
|
+
should_have_generator_attribute :test_helper_filename, 'spec_helper.rb'
|
103
|
+
end
|
104
|
+
|
105
|
+
context "rspec" do
|
106
|
+
setup { @framework = :rspec }
|
107
|
+
should_have_generator_attribute :test_task, 'spec'
|
108
|
+
should_have_generator_attribute :test_dir, 'spec'
|
109
|
+
should_have_generator_attribute :default_task, 'spec'
|
110
|
+
should_have_generator_attribute :feature_support_require, 'rspec/expectations'
|
111
|
+
should_have_generator_attribute :feature_support_extend, nil
|
112
|
+
should_have_generator_attribute :test_pattern, 'spec/**/*_spec.rb'
|
113
|
+
should_have_generator_attribute :test_filename, 'the-perfect-gem_spec.rb'
|
114
|
+
should_have_generator_attribute :test_helper_filename, 'spec_helper.rb'
|
115
|
+
end
|
116
|
+
|
117
|
+
context "micronaut" do
|
118
|
+
setup { @framework = :micronaut }
|
119
|
+
should_have_generator_attribute :test_task, 'examples'
|
120
|
+
should_have_generator_attribute :test_dir, 'examples'
|
121
|
+
should_have_generator_attribute :default_task, 'examples'
|
122
|
+
should_have_generator_attribute :feature_support_require, 'micronaut/expectations'
|
123
|
+
should_have_generator_attribute :feature_support_extend, 'Micronaut::Matchers'
|
124
|
+
should_have_generator_attribute :test_pattern, 'examples/**/*_example.rb'
|
125
|
+
should_have_generator_attribute :test_filename, 'the-perfect-gem_example.rb'
|
126
|
+
should_have_generator_attribute :test_helper_filename, 'example_helper.rb'
|
127
|
+
end
|
128
|
+
|
129
|
+
context "testspec" do
|
130
|
+
setup { @framework = :testspec }
|
131
|
+
should_have_generator_attribute :test_task, 'test'
|
132
|
+
should_have_generator_attribute :test_dir, 'test'
|
133
|
+
should_have_generator_attribute :default_task, 'test'
|
134
|
+
should_have_generator_attribute :feature_support_require, 'test/unit/assertions'
|
135
|
+
should_have_generator_attribute :feature_support_extend, 'Test::Unit::Assertions'
|
136
|
+
should_have_generator_attribute :test_pattern, 'test/**/*_test.rb'
|
137
|
+
should_have_generator_attribute :test_filename, 'the-perfect-gem_test.rb'
|
138
|
+
should_have_generator_attribute :test_helper_filename, 'test_helper.rb'
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
@@ -0,0 +1,164 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestGeneratorInitialization < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
set_default_git_config
|
6
|
+
end
|
7
|
+
|
8
|
+
context "given a nil github repo name" do
|
9
|
+
setup do
|
10
|
+
stub_git_config
|
11
|
+
end
|
12
|
+
|
13
|
+
should 'raise NoGithubRepoNameGiven' do
|
14
|
+
assert_raise Jeweler::NoGitHubRepoNameGiven do
|
15
|
+
Jeweler::Generator.new()
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "without git user's name set" do
|
21
|
+
setup do
|
22
|
+
stub_git_config
|
23
|
+
end
|
24
|
+
|
25
|
+
should 'raise an NoGitUserName' do
|
26
|
+
assert_raise Jeweler::NoGitUserName do
|
27
|
+
Jeweler::Generator.new(:project_name => @project_name, :testing_framework => :shoulda, :documentation_framework => :rdoc)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "without git user's email set" do
|
33
|
+
setup do
|
34
|
+
stub_git_config
|
35
|
+
end
|
36
|
+
|
37
|
+
should 'raise NoGitUserEmail' do
|
38
|
+
assert_raise Jeweler::NoGitUserEmail do
|
39
|
+
Jeweler::Generator.new(:project_name => @project_name, :user_name => @git_name, :testing_framework => :shoulda, :documentation_framework => :rdoc)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "without github username set" do
|
45
|
+
setup do
|
46
|
+
stub_git_config
|
47
|
+
end
|
48
|
+
|
49
|
+
should 'raise NotGitHubUser' do
|
50
|
+
assert_raise Jeweler::NoGitHubUser do
|
51
|
+
Jeweler::Generator.new(:project_name => @project_name, :user_name => @git_name, :user_email => @git_email, :testing_framework => :shoulda, :documentation_framework => :rdoc)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "without github token set" do
|
57
|
+
setup do
|
58
|
+
stub_git_config
|
59
|
+
end
|
60
|
+
|
61
|
+
should 'raise NoGitHubToken if creating repo' do
|
62
|
+
assert_raise Jeweler::NoGitHubToken do
|
63
|
+
Jeweler::Generator.new(:project_name => @project_name, :user_name => @git_name, :user_email => @git_email, :github_username => @github_user, :create_repo => true, :testing_framework => :shoulda, :documentation_framework => :rdoc)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def build_generator(options = {})
|
69
|
+
defaults = { :project_name => @project_name,
|
70
|
+
:user_name => @git_name,
|
71
|
+
:user_email => @git_email,
|
72
|
+
:github_username => @github_user,
|
73
|
+
:github_token => @github_token,
|
74
|
+
:testing_framework => :shoulda,
|
75
|
+
:documentation_framework => :rdoc }
|
76
|
+
|
77
|
+
options = defaults.merge(options)
|
78
|
+
Jeweler::Generator.new(options)
|
79
|
+
end
|
80
|
+
|
81
|
+
context "default configuration" do
|
82
|
+
setup do
|
83
|
+
stub_git_config
|
84
|
+
@generator = build_generator
|
85
|
+
end
|
86
|
+
|
87
|
+
should "use shoulda for testing" do
|
88
|
+
assert_equal :shoulda, @generator.testing_framework
|
89
|
+
end
|
90
|
+
|
91
|
+
should "use rdoc for documentation" do
|
92
|
+
assert_equal :rdoc, @generator.documentation_framework
|
93
|
+
end
|
94
|
+
|
95
|
+
should "set todo in summary" do
|
96
|
+
assert_match /todo/i, @generator.summary
|
97
|
+
end
|
98
|
+
|
99
|
+
should "set todo in description" do
|
100
|
+
assert_match /todo/i, @generator.description
|
101
|
+
end
|
102
|
+
|
103
|
+
should "set target directory to the project name" do
|
104
|
+
assert_equal @project_name, File.split(@generator.target_dir).last
|
105
|
+
end
|
106
|
+
|
107
|
+
should "set user's name from git config" do
|
108
|
+
assert_equal @git_name, @generator.user_name
|
109
|
+
end
|
110
|
+
|
111
|
+
should "set email from git config" do
|
112
|
+
assert_equal @git_email, @generator.user_email
|
113
|
+
end
|
114
|
+
|
115
|
+
should "set origin remote as github, based on username and project name" do
|
116
|
+
assert_equal "git@github.com:#{@github_user}/#{@project_name}.git", @generator.git_remote
|
117
|
+
end
|
118
|
+
|
119
|
+
should "set homepage as github based on username and project name" do
|
120
|
+
assert_equal "http://github.com/#{@github_user}/#{@project_name}", @generator.homepage
|
121
|
+
end
|
122
|
+
|
123
|
+
should "set github username from git config" do
|
124
|
+
assert_equal @github_user, @generator.github_username
|
125
|
+
end
|
126
|
+
|
127
|
+
should "set project name as the-perfect-gem" do
|
128
|
+
assert_equal @project_name, @generator.project_name
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
context "using yard" do
|
133
|
+
setup do
|
134
|
+
@generator = build_generator(:documentation_framework => :yard)
|
135
|
+
end
|
136
|
+
|
137
|
+
should "set the doc_task to yardoc" do
|
138
|
+
assert_equal "yardoc", @generator.doc_task
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
context "using rdoc" do
|
144
|
+
setup do
|
145
|
+
@generator = build_generator(:documentation_framework => :rdoc)
|
146
|
+
end
|
147
|
+
|
148
|
+
should "set the doc_task to rdoc" do
|
149
|
+
assert_equal "rdoc", @generator.doc_task
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
context "using a custom homepage" do
|
154
|
+
setup do
|
155
|
+
@generator = build_generator(:homepage => 'http://zomg.com')
|
156
|
+
end
|
157
|
+
|
158
|
+
should "set the homepage" do
|
159
|
+
assert_equal "http://zomg.com", @generator.homepage
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|