jeweler 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/.gitignore +1 -0
  2. data/README.markdown +28 -40
  3. data/Rakefile +25 -31
  4. data/VERSION.yml +3 -2
  5. data/bin/jeweler +1 -4
  6. data/features/generator/cucumber.feature +3 -3
  7. data/features/generator/directory_layout.feature +6 -6
  8. data/features/generator/git.feature +6 -6
  9. data/features/generator/rakefile.feature +17 -17
  10. data/features/generator/test.feature +10 -3
  11. data/features/generator/test_helper.feature +16 -9
  12. data/features/step_definitions/filesystem_steps.rb +2 -2
  13. data/features/step_definitions/generator_steps.rb +11 -4
  14. data/features/support/env.rb +1 -1
  15. data/features/tasks/version.feature +7 -0
  16. data/features/tasks/version_bumping.feature +16 -0
  17. data/jeweler.gemspec +60 -34
  18. data/lib/jeweler.rb +49 -27
  19. data/lib/jeweler/commands.rb +22 -14
  20. data/lib/jeweler/commands/build_gem.rb +6 -1
  21. data/lib/jeweler/commands/install_gem.rb +1 -1
  22. data/lib/jeweler/commands/release_to_git.rb +57 -0
  23. data/lib/jeweler/commands/{release.rb → release_to_github.rb} +2 -22
  24. data/lib/jeweler/commands/release_to_rubyforge.rb +4 -3
  25. data/lib/jeweler/commands/setup_rubyforge.rb +7 -1
  26. data/lib/jeweler/commands/version/write.rb +2 -2
  27. data/lib/jeweler/commands/write_gemspec.rb +5 -3
  28. data/lib/jeweler/gemcutter_tasks.rb +2 -1
  29. data/lib/jeweler/gemspec_helper.rb +27 -14
  30. data/lib/jeweler/generator.rb +60 -82
  31. data/lib/jeweler/generator/application.rb +5 -7
  32. data/lib/jeweler/generator/bacon_mixin.rb +1 -1
  33. data/lib/jeweler/generator/github_mixin.rb +29 -0
  34. data/lib/jeweler/generator/micronaut_mixin.rb +1 -1
  35. data/lib/jeweler/generator/minitest_mixin.rb +6 -6
  36. data/lib/jeweler/generator/options.rb +67 -11
  37. data/lib/jeweler/generator/riot_mixin.rb +42 -0
  38. data/lib/jeweler/generator/rspec_mixin.rb +1 -1
  39. data/lib/jeweler/generator/shoulda_mixin.rb +4 -4
  40. data/lib/jeweler/generator/testspec_mixin.rb +42 -0
  41. data/lib/jeweler/generator/testunit_mixin.rb +3 -3
  42. data/lib/jeweler/generator/yard_mixin.rb +1 -1
  43. data/lib/jeweler/rubyforge_tasks.rb +42 -24
  44. data/lib/jeweler/specification.rb +11 -5
  45. data/lib/jeweler/tasks.rb +78 -41
  46. data/lib/jeweler/templates/.gitignore +17 -1
  47. data/lib/jeweler/templates/Rakefile +4 -8
  48. data/lib/jeweler/templates/minitest/flunking.rb +2 -2
  49. data/lib/jeweler/templates/minitest/helper.rb +3 -3
  50. data/lib/jeweler/templates/riot/flunking.rb +11 -0
  51. data/lib/jeweler/templates/riot/helper.rb +3 -0
  52. data/lib/jeweler/templates/rspec/spec.opts +1 -0
  53. data/lib/jeweler/templates/shoulda/flunking.rb +2 -2
  54. data/lib/jeweler/templates/testspec/flunking.rb +7 -0
  55. data/lib/jeweler/templates/testspec/helper.rb +7 -0
  56. data/lib/jeweler/templates/testunit/flunking.rb +2 -2
  57. data/lib/jeweler/version_helper.rb +14 -5
  58. data/test/fixtures/existing-project-with-version-constant/.document +5 -0
  59. data/test/fixtures/existing-project-with-version-constant/.gitignore +5 -0
  60. data/test/fixtures/existing-project-with-version-constant/LICENSE +20 -0
  61. data/test/fixtures/existing-project-with-version-constant/README.rdoc +7 -0
  62. data/test/fixtures/existing-project-with-version-constant/Rakefile +83 -0
  63. data/test/fixtures/existing-project-with-version-constant/existing-project-with-version.gemspec +29 -0
  64. data/test/fixtures/existing-project-with-version-constant/lib/existing_project_with_version.rb +0 -0
  65. data/test/fixtures/existing-project-with-version-constant/test/existing_project_with_version_test.rb +7 -0
  66. data/test/fixtures/existing-project-with-version-constant/test/test_helper.rb +10 -0
  67. data/test/jeweler/commands/test_build_gem.rb +54 -23
  68. data/test/jeweler/commands/test_install_gem.rb +4 -4
  69. data/test/jeweler/commands/test_release_to_git.rb +201 -0
  70. data/test/jeweler/commands/{test_release.rb → test_release_to_github.rb} +10 -49
  71. data/test/jeweler/commands/test_release_to_rubyforge.rb +0 -4
  72. data/test/jeweler/commands/test_setup_rubyforge.rb +0 -4
  73. data/test/jeweler/commands/test_write_gemspec.rb +11 -2
  74. data/test/jeweler/commands/version/test_write.rb +1 -2
  75. data/test/{test_application.rb → jeweler/generator/test_application.rb} +23 -50
  76. data/test/{test_options.rb → jeweler/generator/test_options.rb} +72 -8
  77. data/test/{test_gemspec_helper.rb → jeweler/test_gemspec_helper.rb} +5 -1
  78. data/test/{test_generator.rb → jeweler/test_generator.rb} +32 -76
  79. data/test/{test_generator_initialization.rb → jeweler/test_generator_initialization.rb} +43 -35
  80. data/test/{test_generator_mixins.rb → jeweler/test_generator_mixins.rb} +8 -3
  81. data/test/{test_specification.rb → jeweler/test_specification.rb} +0 -0
  82. data/test/jeweler/test_tasks.rb +50 -0
  83. data/test/{test_version_helper.rb → jeweler/test_version_helper.rb} +66 -5
  84. data/test/test_helper.rb +20 -2
  85. data/test/test_jeweler.rb +21 -8
  86. metadata +58 -26
  87. data/ROADMAP +0 -12
  88. data/test/test_tasks.rb +0 -35
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  class Jeweler
4
4
  module Commands
5
- class TestRelease < Test::Unit::TestCase
5
+ class TestReleaseToGithub < Test::Unit::TestCase
6
6
 
7
7
  rubyforge_command_context "running" do
8
8
  context "happily" do
@@ -19,7 +19,6 @@ class Jeweler
19
19
  stub(@repo).push
20
20
 
21
21
  stub(@command).release_not_tagged? { true }
22
- stub(@command).tag_release!
23
22
 
24
23
  @command.run
25
24
  end
@@ -40,10 +39,6 @@ class Jeweler
40
39
  assert_received(@repo) {|repo| repo.push }
41
40
  end
42
41
 
43
- should "tag release" do
44
- assert_received(@command) {|command| command.tag_release! }
45
- end
46
-
47
42
  end
48
43
 
49
44
  context "with an unclean staging area" do
@@ -72,7 +67,6 @@ class Jeweler
72
67
  stub(@repo).push
73
68
 
74
69
  stub(@command).release_not_tagged? { true }
75
- stub(@command).tag_release!
76
70
 
77
71
  @command.run
78
72
  end
@@ -89,10 +83,6 @@ class Jeweler
89
83
  assert_received(@repo) {|repo| repo.push }
90
84
  end
91
85
 
92
- should "tag release" do
93
- assert_received(@command) {|command| command.tag_release! }
94
- end
95
-
96
86
  end
97
87
 
98
88
  context "with a release already tagged" do
@@ -109,7 +99,6 @@ class Jeweler
109
99
  stub(@repo).push
110
100
 
111
101
  stub(@command).release_not_tagged? { false }
112
- dont_allow(@command).tag_release!
113
102
 
114
103
  @command.run
115
104
  end
@@ -137,7 +126,7 @@ class Jeweler
137
126
 
138
127
  build_command_context "building from jeweler" do
139
128
  setup do
140
- @command = Jeweler::Commands::Release.build_for(@jeweler)
129
+ @command = Jeweler::Commands::ReleaseToGithub.build_for(@jeweler)
141
130
  end
142
131
 
143
132
  should "assign gemspec" do
@@ -170,7 +159,7 @@ class Jeweler
170
159
  should "be false if there added files" do
171
160
  repo = build_repo :added => %w(README)
172
161
 
173
- command = Jeweler::Commands::Release.new :repo => repo
162
+ command = Jeweler::Commands::ReleaseToGithub.new :repo => repo
174
163
 
175
164
  assert ! command.clean_staging_area?
176
165
  end
@@ -178,7 +167,7 @@ class Jeweler
178
167
  should "be false if there are changed files" do
179
168
  repo = build_repo :changed => %w(README)
180
169
 
181
- command = Jeweler::Commands::Release.new
170
+ command = Jeweler::Commands::ReleaseToGithub.new
182
171
  command.repo = repo
183
172
 
184
173
  assert ! command.clean_staging_area?
@@ -187,7 +176,7 @@ class Jeweler
187
176
  should "be false if there are deleted files" do
188
177
  repo = build_repo :deleted => %w(README)
189
178
 
190
- command = Jeweler::Commands::Release.new
179
+ command = Jeweler::Commands::ReleaseToGithub.new
191
180
  command.repo = repo
192
181
 
193
182
  assert ! command.clean_staging_area?
@@ -196,41 +185,13 @@ class Jeweler
196
185
  should "be true if nothing added, changed, or deleted" do
197
186
  repo = build_repo
198
187
 
199
- command = Jeweler::Commands::Release.new
188
+ command = Jeweler::Commands::ReleaseToGithub.new
200
189
  command.repo = repo
201
190
 
202
191
  assert command.clean_staging_area?
203
192
  end
204
193
  end
205
194
 
206
- context "tag_release!" do
207
- setup do
208
- @repo = Object.new
209
- stub(@repo) do
210
- add_tag(anything)
211
- push(anything, anything)
212
- end
213
-
214
- @output = StringIO.new
215
-
216
- @command = Jeweler::Commands::Release.new
217
- @command.output = @output
218
- @command.repo = @repo
219
- @command.gemspec_helper = @gemspec_helper
220
- @command.version = '1.2.3'
221
-
222
- @command.tag_release!
223
- end
224
-
225
- should "tag release" do
226
- assert_received(@repo) {|repo| repo.add_tag("v1.2.3")}
227
- end
228
-
229
- should "push tag to repository" do
230
- assert_received(@repo) {|repo| repo.push('origin', 'v1.2.3')}
231
- end
232
- end
233
-
234
195
  context "regenerate_gemspec!" do
235
196
  setup do
236
197
  @repo = Object.new
@@ -248,7 +209,7 @@ class Jeweler
248
209
 
249
210
  @output = StringIO.new
250
211
 
251
- @command = Jeweler::Commands::Release.new :output => @output,
212
+ @command = Jeweler::Commands::ReleaseToGithub.new :output => @output,
252
213
  :repo => @repo,
253
214
  :gemspec_helper => @gemspec_helper,
254
215
  :version => '1.2.3'
@@ -281,7 +242,7 @@ class Jeweler
281
242
 
282
243
  @output = StringIO.new
283
244
 
284
- @command = Jeweler::Commands::Release.new :output => @output,
245
+ @command = Jeweler::Commands::ReleaseToGithub.new :output => @output,
285
246
  :repo => @repo,
286
247
  :gemspec_helper => @gemspec_helper,
287
248
  :version => '1.2.3'
@@ -306,7 +267,7 @@ class Jeweler
306
267
 
307
268
  @output = StringIO.new
308
269
 
309
- @command = Jeweler::Commands::Release.new
270
+ @command = Jeweler::Commands::ReleaseToGithub.new
310
271
  @command.output = @output
311
272
  @command.repo = @repo
312
273
  @command.version = '1.2.3'
@@ -327,7 +288,7 @@ class Jeweler
327
288
 
328
289
  @output = StringIO.new
329
290
 
330
- @command = Jeweler::Commands::Release.new
291
+ @command = Jeweler::Commands::ReleaseToGithub.new
331
292
  @command.output = @output
332
293
  @command.repo = @repo
333
294
  @command.version = '1.2.3'
@@ -146,10 +146,6 @@ class Jeweler
146
146
  should "assign output" do
147
147
  assert_equal @output, @command.output
148
148
  end
149
-
150
- should "assign rubyforge" do
151
- assert_equal @rubyforge, @command.rubyforge
152
- end
153
149
  end
154
150
 
155
151
  end
@@ -171,10 +171,6 @@ class Jeweler
171
171
  should "assign output" do
172
172
  assert_equal @output, @command.output
173
173
  end
174
-
175
- should "assign rubyforge" do
176
- assert_equal @rubyforge, @command.rubyforge
177
- end
178
174
  end
179
175
 
180
176
  end
@@ -27,27 +27,36 @@ class Jeweler
27
27
 
28
28
  @now = Time.now
29
29
  stub(Time.now).now { @now }
30
-
31
- @command.run
32
30
  end
33
31
 
34
32
  should "refresh version" do
33
+ @command.run
35
34
  assert_received(@version_helper) {|version_helper| version_helper.refresh }
36
35
  end
37
36
 
38
37
  should "update gemspec version" do
38
+ @command.run
39
39
  assert_equal '1.2.3', @gemspec.version.to_s
40
40
  end
41
41
 
42
+ should "not refresh version neither update version if it's set on the gemspec" do
43
+ @gemspec.version = '2.3.4'
44
+ @command.run
45
+ assert_equal '2.3.4', @gemspec.version.to_s
46
+ end
47
+
42
48
  should "update gemspec date to the beginning of today" do
49
+ @command.run
43
50
  assert_equal Time.mktime(@now.year, @now.month, @now.day, 0, 0), @gemspec.date
44
51
  end
45
52
 
46
53
  should "write gemspec" do
54
+ @command.run
47
55
  assert_received(@gemspec_helper) {|gemspec_helper| gemspec_helper.write }
48
56
  end
49
57
 
50
58
  should_eventually "output that the gemspec was written" do
59
+ @command.run
51
60
  assert_equal @output.string, "Generated: tmp/zomg.gemspec"
52
61
  end
53
62
 
@@ -6,14 +6,13 @@ class Jeweler
6
6
  class TestWrite < Test::Unit::TestCase
7
7
 
8
8
  should "call write_version on version_helper in update_version" do
9
- mock(version_helper = Object.new).update_to 1, 2, 3
9
+ mock(version_helper = Object.new).update_to 1, 2, 3, nil
10
10
 
11
11
  command = Jeweler::Commands::Version::Write.new
12
12
  command.version_helper = version_helper
13
13
  command.major = 1
14
14
  command.minor = 2
15
15
  command.patch = 3
16
-
17
16
  command.update_version
18
17
  end
19
18
  end
@@ -25,40 +25,23 @@ class TestApplication < Test::Unit::TestCase
25
25
  result
26
26
  end
27
27
 
28
- def self.should_exit_with_code(code)
29
- should "exit with code #{code}" do
30
- assert_equal code, @result
31
- end
32
- end
33
-
34
- context "called without any args" do
35
- setup do
36
- @result = run_application
37
- end
28
+ def stub_options(options)
29
+ stub(options).opts { 'Usage:' }
38
30
 
39
- should_exit_with_code 1
40
-
41
- should 'display usage on stderr' do
42
- assert_match 'Usage:', @stderr
43
- end
31
+ stub(Jeweler::Generator::Options).new { options }
44
32
 
45
- should 'not display anything on stdout' do
46
- assert_equal '', @stdout.squeeze.strip
47
- end
33
+ options
48
34
  end
49
35
 
50
- def build_generator(name = 'zomg', options = {:testing_framework => :shoulda})
51
- stub(Git).global_config() do
52
- {'user.name' => 'John Doe', 'user.email' => 'john@example.com', 'github.user' => 'johndoe', 'github.token' => 'yyz'}
36
+ def self.should_exit_with_code(code)
37
+ should "exit with code #{code}" do
38
+ assert_equal code, @result
53
39
  end
54
-
55
- Jeweler::Generator.new(name, options)
56
40
  end
57
41
 
58
- context "called with -h" do
42
+ context "when options indicate help usage" do
59
43
  setup do
60
- @generator = build_generator
61
- stub(@generator).run
44
+ stub_options :show_help => true
62
45
  stub(Jeweler::Generator).new { raise "Shouldn't have made this far"}
63
46
 
64
47
  assert_nothing_raised do
@@ -68,7 +51,7 @@ class TestApplication < Test::Unit::TestCase
68
51
 
69
52
  should_exit_with_code 1
70
53
 
71
- should 'display usage on stderr' do
54
+ should 'should puts option usage' do
72
55
  assert_match 'Usage:', @stderr
73
56
  end
74
57
 
@@ -77,10 +60,9 @@ class TestApplication < Test::Unit::TestCase
77
60
  end
78
61
  end
79
62
 
80
- context "called with --invalid-argument" do
63
+ context "when options indicate an invalid argument" do
81
64
  setup do
82
- @generator = build_generator
83
- stub(@generator).run
65
+ stub_options :invalid_argument => '--invalid-argument'
84
66
  stub(Jeweler::Generator).new { raise "Shouldn't have made this far"}
85
67
 
86
68
  assert_nothing_raised do
@@ -101,38 +83,29 @@ class TestApplication < Test::Unit::TestCase
101
83
  should 'not display anything on stdout' do
102
84
  assert_equal '', @stdout.squeeze.strip
103
85
  end
86
+
104
87
  end
105
88
 
106
- context "when called with repo name" do
89
+ context "when options are good" do
107
90
  setup do
108
- @options = {:testing_framework => :shoulda, :documentation_framework => :rdoc}
109
- @generator = build_generator('zomg', @options)
110
-
91
+ @options = stub_options :project_name => 'zomg'
92
+ @generator = "generator"
111
93
  stub(@generator).run
112
94
  stub(Jeweler::Generator).new { @generator }
113
- end
114
-
115
- should 'return exit code 0' do
116
- result = run_application("zomg")
117
- assert_equal 0, result
118
- end
119
-
120
- should 'create generator with repo name and no options' do
121
- run_application("zomg")
122
95
 
123
- assert_received Jeweler::Generator do |subject|
124
- subject.new('zomg', @options)
96
+ assert_nothing_raised do
97
+ @result = run_application("zomg")
125
98
  end
126
99
  end
127
100
 
128
- should 'run generator' do
129
- run_application("zomg")
101
+ should_exit_with_code 0
130
102
 
131
- assert_received(@generator) {|subject| subject.run }
103
+ should "create generator with options" do
104
+ assert_received(Jeweler::Generator) {|subject| subject.new(@options) }
132
105
  end
133
106
 
134
- should 'not display usage on stderr' do
135
- assert_no_match /Usage:/, @stderr
107
+ should "run generator" do
108
+ assert_received(@generator) {|subject| subject.run }
136
109
  end
137
110
  end
138
111
 
@@ -2,6 +2,11 @@ require 'test_helper'
2
2
 
3
3
  class TestOptions < Test::Unit::TestCase
4
4
 
5
+ def setup
6
+ set_default_git_config
7
+ stub_git_config valid_git_config
8
+ end
9
+
5
10
  def self.should_have_testing_framework(testing_framework)
6
11
  should "use #{testing_framework} for testing" do
7
12
  assert_equal testing_framework.to_sym, @options[:testing_framework]
@@ -15,7 +20,7 @@ class TestOptions < Test::Unit::TestCase
15
20
  end
16
21
 
17
22
  def setup_options(*arguments)
18
- @options = Jeweler::Generator::Options.new(arguments)
23
+ @options = Jeweler::Generator::Options.new(["project_name"] + arguments)
19
24
  end
20
25
 
21
26
  def self.for_options(*options)
@@ -32,18 +37,33 @@ class TestOptions < Test::Unit::TestCase
32
37
  should 'not create repository' do
33
38
  assert ! @options[:create_repo]
34
39
  end
35
- end
40
+ should "have project name" do
41
+ assert_equal "project_name", @options[:project_name]
42
+ end
36
43
 
37
- for_options '--shoulda' do
38
- should_have_testing_framework :shoulda
44
+ should "use github username from git config" do
45
+ assert_equal @github_user, @options[:github_username]
46
+ end
47
+
48
+ should "use github token from git config" do
49
+ assert_equal @github_token, @options[:github_token]
50
+ end
51
+
52
+ should "use user name from git config" do
53
+ assert_equal @git_name, @options[:user_name]
54
+ end
55
+
56
+ should "use user email from git config" do
57
+ assert_equal @git_email, @options[:user_email]
58
+ end
39
59
  end
40
60
 
41
61
  for_options "--bacon" do
42
62
  should_have_testing_framework :bacon
43
63
  end
44
64
 
45
- for_options "--testunit" do
46
- should_have_testing_framework :testunit
65
+ for_options '--micronaut' do
66
+ should_have_testing_framework :micronaut
47
67
  end
48
68
 
49
69
  for_options '--minitest' do
@@ -54,8 +74,16 @@ class TestOptions < Test::Unit::TestCase
54
74
  should_have_testing_framework :rspec
55
75
  end
56
76
 
57
- for_options '--micronaut' do
58
- should_have_testing_framework :micronaut
77
+ for_options '--shoulda' do
78
+ should_have_testing_framework :shoulda
79
+ end
80
+
81
+ for_options "--testunit" do
82
+ should_have_testing_framework :testunit
83
+ end
84
+
85
+ for_options "--testspec" do
86
+ should_have_testing_framework :testspec
59
87
  end
60
88
 
61
89
  for_options '--cucumber' do
@@ -132,6 +160,42 @@ class TestOptions < Test::Unit::TestCase
132
160
  end
133
161
  end
134
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
+
135
199
  context "merging options" do
136
200
  should "take options from each" do
137
201
  options = Jeweler::Generator::Options.new(["--rspec"]).