jeweler 1.4.0 → 1.5.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. data/.document +14 -0
  2. data/.gitignore +13 -2
  3. data/ChangeLog.markdown +8 -8
  4. data/Gemfile +21 -0
  5. data/Gemfile.lock +57 -0
  6. data/README.markdown +6 -6
  7. data/Rakefile +32 -46
  8. data/features/generator/cucumber.feature +20 -0
  9. data/features/generator/directory_layout.feature +10 -0
  10. data/features/generator/gemfile.feature +71 -0
  11. data/features/generator/git.feature +8 -0
  12. data/features/generator/license.feature +11 -2
  13. data/features/generator/rakefile.feature +25 -23
  14. data/features/generator/test.feature +6 -0
  15. data/features/generator/test_helper.feature +107 -11
  16. data/features/step_definitions/filesystem_steps.rb +5 -3
  17. data/features/step_definitions/generator_steps.rb +68 -4
  18. data/features/support/env.rb +26 -13
  19. data/jeweler.gemspec +222 -207
  20. data/lib/jeweler.rb +7 -5
  21. data/lib/jeweler/commands.rb +1 -3
  22. data/lib/jeweler/commands/check_dependencies.rb +3 -5
  23. data/lib/jeweler/commands/install_gem.rb +1 -2
  24. data/lib/jeweler/commands/release_to_git.rb +5 -3
  25. data/lib/jeweler/commands/release_to_github.rb +24 -8
  26. data/lib/jeweler/commands/{release_to_gemcutter.rb → release_to_rubygems.rb} +1 -2
  27. data/lib/jeweler/commands/version/base.rb +16 -2
  28. data/lib/jeweler/commands/write_gemspec.rb +0 -1
  29. data/lib/jeweler/errors.rb +4 -16
  30. data/lib/jeweler/gemcutter_tasks.rb +4 -32
  31. data/lib/jeweler/gemspec_helper.rb +3 -6
  32. data/lib/jeweler/generator.rb +23 -6
  33. data/lib/jeweler/generator/options.rb +17 -14
  34. data/lib/jeweler/generator/rspec_mixin.rb +1 -1
  35. data/lib/jeweler/generator/shindo_mixin.rb +44 -0
  36. data/lib/jeweler/generator/shoulda_mixin.rb +1 -1
  37. data/lib/jeweler/rubyforge_tasks.rb +5 -29
  38. data/lib/jeweler/rubygems_dot_org_tasks.rb +38 -0
  39. data/lib/jeweler/rubygems_tasks.rb +38 -0
  40. data/lib/jeweler/specification.rb +36 -12
  41. data/lib/jeweler/tasks.rb +49 -13
  42. data/lib/jeweler/templates/.document +6 -0
  43. data/lib/jeweler/templates/.gitignore +34 -16
  44. data/lib/jeweler/templates/Gemfile +12 -0
  45. data/lib/jeweler/templates/LICENSE +1 -1
  46. data/lib/jeweler/templates/Rakefile +1 -0
  47. data/lib/jeweler/templates/bacon/helper.rb +1 -0
  48. data/lib/jeweler/templates/bundler_setup.erb +10 -0
  49. data/lib/jeweler/templates/features/support/env.rb +2 -0
  50. data/lib/jeweler/templates/jeweler_tasks.erb +20 -23
  51. data/lib/jeweler/templates/micronaut/helper.rb +1 -0
  52. data/lib/jeweler/templates/minitest/helper.rb +1 -0
  53. data/lib/jeweler/templates/other_tasks.erb +27 -59
  54. data/lib/jeweler/templates/riot/helper.rb +1 -0
  55. data/lib/jeweler/templates/rspec/{spec.opts → .rspec} +0 -0
  56. data/lib/jeweler/templates/rspec/helper.rb +7 -3
  57. data/lib/jeweler/templates/shindo/flunking.rb +8 -0
  58. data/lib/jeweler/templates/shindo/helper.rb +6 -0
  59. data/lib/jeweler/templates/shoulda/helper.rb +1 -0
  60. data/lib/jeweler/templates/testunit/helper.rb +1 -0
  61. data/lib/jeweler/version.rb +10 -0
  62. data/lib/jeweler/version_helper.rb +1 -2
  63. data/test/fixtures/existing-project-with-version-constant/Rakefile +4 -2
  64. data/test/fixtures/existing-project-with-version-plaintext/Rakefile +4 -2
  65. data/test/fixtures/existing-project-with-version-yaml/Rakefile +4 -2
  66. data/test/jeweler/commands/test_install_gem.rb +2 -2
  67. data/test/jeweler/commands/test_release_to_gemcutter.rb +4 -4
  68. data/test/jeweler/commands/test_release_to_git.rb +32 -25
  69. data/test/jeweler/commands/test_release_to_github.rb +108 -25
  70. data/test/jeweler/generator/test_options.rb +16 -22
  71. data/test/jeweler/test_generator.rb +5 -0
  72. data/test/jeweler/test_specification.rb +18 -7
  73. data/test/jeweler/test_tasks.rb +1 -1
  74. data/test/test_helper.rb +12 -14
  75. data/test/test_jeweler.rb +0 -12
  76. metadata +159 -66
  77. data/VERSION.yml +0 -5
  78. data/lib/jeweler/commands/release_to_rubyforge.rb +0 -52
  79. data/lib/jeweler/commands/setup_rubyforge.rb +0 -63
  80. data/test/jeweler/commands/test_release_to_rubyforge.rb +0 -153
  81. data/test/jeweler/commands/test_setup_rubyforge.rb +0 -178
@@ -12,7 +12,7 @@ begin
12
12
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
13
13
  end
14
14
  rescue LoadError
15
- puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
15
+ puts "Jeweler not available. Install it with: gem install technicalpickles-jeweler -s http://gems.github.com"
16
16
  end
17
17
 
18
18
  require 'rake/testtask'
@@ -31,7 +31,7 @@ begin
31
31
  end
32
32
  rescue LoadError
33
33
  task :rcov do
34
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
34
+ abort "RCov is not available. In order to run rcov, you must: gem install spicycode-rcov"
35
35
  end
36
36
  end
37
37
 
@@ -41,6 +41,7 @@ task :default => :test
41
41
  require 'rake/rdoctask'
42
42
  Rake::RDocTask.new do |rdoc|
43
43
  if File.exist?('VERSION.yml')
44
+ require 'yaml'
44
45
  config = YAML.load(File.read('VERSION.yml'))
45
46
  version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
46
47
  else
@@ -65,6 +66,7 @@ begin
65
66
  namespace :release do
66
67
  desc "Publish RDoc to RubyForge."
67
68
  task :docs => [:rdoc] do
69
+ require 'yaml'
68
70
  config = YAML.load(
69
71
  File.read(File.expand_path('~/.rubyforge/user-config.yml'))
70
72
  )
@@ -6,14 +6,14 @@ class Jeweler
6
6
  rubyforge_command_context "running" do
7
7
  setup do
8
8
  stub(@gemspec_helper).gem_path { 'pkg/zomg-1.1.1.gem' }
9
- stub(@command).gem_command { 'gem' }
9
+ stub(@command).gem_command { 'ruby -S gem' }
10
10
  stub(@command).sh
11
11
 
12
12
  @command.run
13
13
  end
14
14
 
15
15
  should "call sh with gem install" do
16
- assert_received(@command) {|command| command.sh 'gem install pkg/zomg-1.1.1.gem' }
16
+ assert_received(@command) {|command| command.sh 'ruby -S gem install pkg/zomg-1.1.1.gem' }
17
17
  end
18
18
  end
19
19
 
@@ -2,9 +2,9 @@ require 'test_helper'
2
2
 
3
3
  class Jeweler
4
4
  module Commands
5
- class TestReleaseToGemcutter < Test::Unit::TestCase
5
+ class TestReleaseToRubygems < Test::Unit::TestCase
6
6
  def self.subject
7
- Jeweler::Commands::ReleaseToGemcutter.new
7
+ Jeweler::Commands::ReleaseToRubygems.new
8
8
  end
9
9
 
10
10
  gemcutter_command_context "rubyforge_project is defined in gemspec and package exists on rubyforge" do
@@ -14,7 +14,7 @@ class Jeweler
14
14
  @command.run
15
15
  end
16
16
 
17
- should "push to gemcutter" do
17
+ should "push to rubygems" do
18
18
  push_command = "gem push #{@gemspec_helper.gem_path}"
19
19
  assert_received(@command) { |command| command.sh(push_command) }
20
20
  end
@@ -22,7 +22,7 @@ class Jeweler
22
22
 
23
23
  build_command_context "build for jeweler" do
24
24
  setup do
25
- @command = Jeweler::Commands::ReleaseToGemcutter.build_for(@jeweler)
25
+ @command = Jeweler::Commands::ReleaseToRubygems.build_for(@jeweler)
26
26
  end
27
27
 
28
28
  should "assign gemspec helper" do
@@ -35,6 +35,7 @@ class Jeweler
35
35
  context "with an unclean staging area" do
36
36
  setup do
37
37
  stub(@command).clean_staging_area? { false }
38
+ stub(@command).system
38
39
  end
39
40
 
40
41
  should 'raise error' do
@@ -42,6 +43,11 @@ class Jeweler
42
43
  @command.run
43
44
  end
44
45
  end
46
+
47
+ should 'display git status' do
48
+ @command.run rescue nil
49
+ assert_received(@command) {|command| command.system("git status") }
50
+ end
45
51
  end
46
52
 
47
53
  context "with a release already tagged" do
@@ -100,43 +106,44 @@ class Jeweler
100
106
  end
101
107
  end
102
108
 
103
- context "clean_staging_area?" do
109
+ # FIXME this code had its ruby-git stuff replaced with `` and system, which is much harder to test, so re-enable these someday
110
+ #context "clean_staging_area?" do
104
111
 
105
- should "be false if there added files" do
106
- repo = build_repo :added => %w(README)
112
+ # should "be false if there added files" do
113
+ # repo = build_repo :added => %w(README)
107
114
 
108
- command = Jeweler::Commands::ReleaseToGit.new :repo => repo
115
+ # command = Jeweler::Commands::ReleaseToGit.new :repo => repo
109
116
 
110
- assert ! command.clean_staging_area?
111
- end
117
+ # assert ! command.clean_staging_area?
118
+ # end
112
119
 
113
- should "be false if there are changed files" do
114
- repo = build_repo :changed => %w(README)
120
+ # should "be false if there are changed files" do
121
+ # repo = build_repo :changed => %w(README)
115
122
 
116
- command = Jeweler::Commands::ReleaseToGit.new
117
- command.repo = repo
123
+ # command = Jeweler::Commands::ReleaseToGit.new
124
+ # command.repo = repo
118
125
 
119
- assert ! command.clean_staging_area?
120
- end
126
+ # assert ! command.clean_staging_area?
127
+ # end
121
128
 
122
- should "be false if there are deleted files" do
123
- repo = build_repo :deleted => %w(README)
129
+ # should "be false if there are deleted files" do
130
+ # repo = build_repo :deleted => %w(README)
124
131
 
125
- command = Jeweler::Commands::ReleaseToGit.new
126
- command.repo = repo
132
+ # command = Jeweler::Commands::ReleaseToGit.new
133
+ # command.repo = repo
127
134
 
128
- assert ! command.clean_staging_area?
129
- end
135
+ # assert ! command.clean_staging_area?
136
+ # end
130
137
 
131
- should "be true if nothing added, changed, or deleted" do
132
- repo = build_repo
138
+ # should "be true if nothing added, changed, or deleted" do
139
+ # repo = build_repo
133
140
 
134
- command = Jeweler::Commands::ReleaseToGit.new
135
- command.repo = repo
141
+ # command = Jeweler::Commands::ReleaseToGit.new
142
+ # command.repo = repo
136
143
 
137
- assert command.clean_staging_area?
138
- end
139
- end
144
+ # assert command.clean_staging_area?
145
+ # end
146
+ #end
140
147
 
141
148
  context "release_tagged? when no tag exists" do
142
149
  setup do
@@ -1,4 +1,5 @@
1
1
  require 'test_helper'
2
+ require 'pathname'
2
3
 
3
4
  class Jeweler
4
5
  module Commands
@@ -44,6 +45,7 @@ class Jeweler
44
45
  context "with an unclean staging area" do
45
46
  setup do
46
47
  stub(@command).clean_staging_area? { false }
48
+ stub(@command).system
47
49
  end
48
50
 
49
51
  should 'raise error' do
@@ -51,6 +53,11 @@ class Jeweler
51
53
  @command.run
52
54
  end
53
55
  end
56
+
57
+ should 'display git status' do
58
+ @command.run rescue nil
59
+ assert_received(@command) {|command| command.system("git status") }
60
+ end
54
61
  end
55
62
 
56
63
  context "with an unchanged gemspec" do
@@ -154,43 +161,44 @@ class Jeweler
154
161
  end
155
162
  end
156
163
 
157
- context "clean_staging_area?" do
164
+ # FIXME this code had its ruby-git stuff replaced with `` and system, which is much harder to test, so re-enable these someday
165
+ #context "clean_staging_area?" do
158
166
 
159
- should "be false if there added files" do
160
- repo = build_repo :added => %w(README)
167
+ # should "be false if there added files" do
168
+ # repo = build_repo :added => %w(README)
161
169
 
162
- command = Jeweler::Commands::ReleaseToGithub.new :repo => repo
170
+ # command = Jeweler::Commands::ReleaseToGithub.new :repo => repo
163
171
 
164
- assert ! command.clean_staging_area?
165
- end
172
+ # assert ! command.clean_staging_area?
173
+ # end
166
174
 
167
- should "be false if there are changed files" do
168
- repo = build_repo :changed => %w(README)
175
+ # should "be false if there are changed files" do
176
+ # repo = build_repo :changed => %w(README)
169
177
 
170
- command = Jeweler::Commands::ReleaseToGithub.new
171
- command.repo = repo
178
+ # command = Jeweler::Commands::ReleaseToGithub.new
179
+ # command.repo = repo
172
180
 
173
- assert ! command.clean_staging_area?
174
- end
181
+ # assert ! command.clean_staging_area?
182
+ # end
175
183
 
176
- should "be false if there are deleted files" do
177
- repo = build_repo :deleted => %w(README)
184
+ # should "be false if there are deleted files" do
185
+ # repo = build_repo :deleted => %w(README)
178
186
 
179
- command = Jeweler::Commands::ReleaseToGithub.new
180
- command.repo = repo
187
+ # command = Jeweler::Commands::ReleaseToGithub.new
188
+ # command.repo = repo
181
189
 
182
- assert ! command.clean_staging_area?
183
- end
190
+ # assert ! command.clean_staging_area?
191
+ # end
184
192
 
185
- should "be true if nothing added, changed, or deleted" do
186
- repo = build_repo
193
+ # should "be true if nothing added, changed, or deleted" do
194
+ # repo = build_repo
187
195
 
188
- command = Jeweler::Commands::ReleaseToGithub.new
189
- command.repo = repo
196
+ # command = Jeweler::Commands::ReleaseToGithub.new
197
+ # command.repo = repo
190
198
 
191
- assert command.clean_staging_area?
192
- end
193
- end
199
+ # assert command.clean_staging_area?
200
+ # end
201
+ #end
194
202
 
195
203
  context "regenerate_gemspec!" do
196
204
  setup do
@@ -247,6 +255,7 @@ class Jeweler
247
255
  :gemspec_helper => @gemspec_helper,
248
256
  :version => '1.2.3'
249
257
 
258
+ stub(@command).working_subdir { Pathname.new(".") }
250
259
  @command.commit_gemspec!
251
260
  end
252
261
 
@@ -260,6 +269,80 @@ class Jeweler
260
269
 
261
270
  end
262
271
 
272
+ context "commit_gemspec! in top dir" do
273
+ setup do
274
+ @repo = Object.new
275
+
276
+ stub(@repo) do
277
+ add(anything)
278
+ commit(anything)
279
+ end
280
+
281
+ @gemspec_helper = Object.new
282
+ stub(@gemspec_helper) do
283
+ path {'zomg.gemspec'}
284
+ update_version('1.2.3')
285
+ end
286
+
287
+ @output = StringIO.new
288
+
289
+ @command = Jeweler::Commands::ReleaseToGithub.new :output => @output,
290
+ :repo => @repo,
291
+ :gemspec_helper => @gemspec_helper,
292
+ :version => '1.2.3',
293
+ :base_dir => '.'
294
+
295
+ @dir = Object.new
296
+ stub(@repo).dir { @dir }
297
+ stub(@dir).path { "/x/y/z" }
298
+
299
+ stub(@command).base_dir_path { Pathname.new("/x/y/z") }
300
+
301
+ @command.commit_gemspec!
302
+ end
303
+
304
+ should "add gemspec to repository" do
305
+ assert_received(@repo) {|repo| repo.add('zomg.gemspec') }
306
+ end
307
+ end
308
+
309
+ context "commit_gemspec! in sub dir" do
310
+ setup do
311
+ @repo = Object.new
312
+
313
+ stub(@repo) do
314
+ add(anything)
315
+ commit(anything)
316
+ end
317
+
318
+ @gemspec_helper = Object.new
319
+ stub(@gemspec_helper) do
320
+ path {'zomg.gemspec'}
321
+ update_version('1.2.3')
322
+ end
323
+
324
+ @output = StringIO.new
325
+
326
+ @command = Jeweler::Commands::ReleaseToGithub.new :output => @output,
327
+ :repo => @repo,
328
+ :gemspec_helper => @gemspec_helper,
329
+ :version => '1.2.3',
330
+ :base_dir => '.'
331
+
332
+ @dir = Object.new
333
+ stub(@repo).dir { @dir }
334
+ stub(@dir).path { "/x/y/z" }
335
+
336
+ stub(@command).base_dir_path { Pathname.new("/x/y/z/gem") }
337
+
338
+ @command.commit_gemspec!
339
+ end
340
+
341
+ should "add gemspec to repository" do
342
+ assert_received(@repo) {|repo| repo.add('gem/zomg.gemspec') }
343
+ end
344
+ end
345
+
263
346
  context "release_tagged? when no tag exists" do
264
347
  setup do
265
348
  @repo = Object.new
@@ -39,10 +39,6 @@ class TestOptions < Test::Unit::TestCase
39
39
  assert ! @options[:create_repo]
40
40
  end
41
41
 
42
- should 'use gemcutter' do
43
- assert @options[:gemcutter]
44
- end
45
-
46
42
  should "have project name" do
47
43
  assert_equal "project_name", @options[:project_name]
48
44
  end
@@ -62,6 +58,10 @@ class TestOptions < Test::Unit::TestCase
62
58
  should "use user email from git config" do
63
59
  assert_equal @git_email, @options[:user_email]
64
60
  end
61
+
62
+ should "use bundler" do
63
+ assert @options[:use_bundler]
64
+ end
65
65
  end
66
66
 
67
67
  for_options "--bacon" do
@@ -116,24 +116,6 @@ class TestOptions < Test::Unit::TestCase
116
116
  end
117
117
  end
118
118
 
119
- for_options '--rubyforge' do
120
- should 'enable rubyforge' do
121
- assert @options[:rubyforge]
122
- end
123
- end
124
-
125
- for_options '--no-gemcutter' do
126
- should 'enable rubyforge' do
127
- assert ! @options[:gemcutter]
128
- end
129
- end
130
-
131
- for_options '--gemcutter' do
132
- should 'enable rubyforge' do
133
- assert @options[:gemcutter]
134
- end
135
- end
136
-
137
119
  for_options '--rdoc' do
138
120
  should_have_docmentation_framework :rdoc
139
121
  end
@@ -214,6 +196,18 @@ class TestOptions < Test::Unit::TestCase
214
196
  end
215
197
  end
216
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
+
217
211
  context "merging options" do
218
212
  should "take options from each" do
219
213
  options = Jeweler::Generator::Options.new(["--rspec"]).
@@ -28,6 +28,11 @@ class TestGenerator < Test::Unit::TestCase
28
28
  should "have the correct lib file name" do
29
29
  assert_equal "the-perfect-gem.rb", build_generator.lib_filename
30
30
  end
31
+
32
+ should "have the correct git-remote" do
33
+ assert_equal 'user@host:/path/to/repo', build_generator(:shoulda, {:git_remote => "user@host:/path/to/repo"}).git_remote
34
+ assert_equal 'git@github.com:johndoe/the-perfect-gem.git', build_generator.git_remote
35
+ end
31
36
 
32
37
  def self.should_have_generator_attribute(attribute, value)
33
38
  should "have #{value} for #{attribute}" do
@@ -19,6 +19,13 @@ class TestSpecification < Test::Unit::TestCase
19
19
  gemspec
20
20
  end
21
21
 
22
+ should "be able to use to_ruby on a duped gemspec without error" do
23
+ gemspec = build_jeweler_gemspec
24
+ gemspec.files.include 'throwaway value'
25
+
26
+ gemspec.dup.to_ruby
27
+ end
28
+
22
29
  context "basic defaults" do
23
30
  setup do
24
31
  @gemspec = build_jeweler_gemspec
@@ -78,6 +85,9 @@ class TestSpecification < Test::Unit::TestCase
78
85
  bin.file 'burnination'
79
86
  bin.file 'trogdor'
80
87
  end
88
+ repo = Git.init(@project.to_s)
89
+ repo.add('bin/burnination')
90
+ repo.commit('Initial commit')
81
91
  end
82
92
 
83
93
  context "and there hasn't been any set on the gemspec" do
@@ -86,8 +96,8 @@ class TestSpecification < Test::Unit::TestCase
86
96
  @gemspec.set_jeweler_defaults(@project)
87
97
  end
88
98
 
89
- should "have the executables in the gemspec" do
90
- assert_equal %w(burnination trogdor), @gemspec.executables
99
+ should "have the executables under version control in the gemspec" do
100
+ assert_equal %w(burnination), @gemspec.executables
91
101
  end
92
102
  end
93
103
  context "and has been previously set executables" do
@@ -134,7 +144,7 @@ class TestSpecification < Test::Unit::TestCase
134
144
  lib.file 'example.rb'
135
145
  end
136
146
 
137
- repo = Git.init(@project)
147
+ repo = Git.init(@project.to_s)
138
148
  repo.add('.')
139
149
  repo.commit('Initial commit')
140
150
  end
@@ -146,7 +156,7 @@ class TestSpecification < Test::Unit::TestCase
146
156
  end
147
157
 
148
158
  should "populate files from git" do
149
- assert_equal %w(Rakefile lib/example.rb), @gemspec.files
159
+ assert_equal %w(Rakefile lib/example.rb), @gemspec.files.sort
150
160
  end
151
161
  end
152
162
 
@@ -174,7 +184,7 @@ class TestSpecification < Test::Unit::TestCase
174
184
  lib.file 'example.rb'
175
185
  end
176
186
 
177
- repo = Git.init(@project)
187
+ repo = Git.init(@project.to_s)
178
188
  repo.add('.')
179
189
  repo.commit('Initial commit')
180
190
 
@@ -184,7 +194,7 @@ class TestSpecification < Test::Unit::TestCase
184
194
  end
185
195
 
186
196
  should "populate files from git excluding ignored" do
187
- assert_equal %w(.gitignore Rakefile lib/example.rb), @gemspec.files
197
+ assert_equal %w(.gitignore Rakefile lib/example.rb), @gemspec.files.sort
188
198
  end
189
199
  end
190
200
 
@@ -200,7 +210,7 @@ class TestSpecification < Test::Unit::TestCase
200
210
  end
201
211
  end
202
212
 
203
- repo = Git.init(@project)
213
+ repo = Git.init(@project.to_s)
204
214
  repo.add('.')
205
215
  repo.commit('Initial commit')
206
216
 
@@ -228,4 +238,5 @@ class TestSpecification < Test::Unit::TestCase
228
238
  assert_equal [], @gemspec.files.sort
229
239
  end
230
240
  end
241
+
231
242
  end