jeweler 1.8.2 → 2.3.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +2 -0
  3. data/.semver +5 -0
  4. data/.travis.yml +5 -3
  5. data/ChangeLog.markdown +30 -0
  6. data/Gemfile +32 -25
  7. data/Gemfile.lock +117 -46
  8. data/README.markdown +36 -10
  9. data/README.org +374 -0
  10. data/Rakefile +23 -28
  11. data/bin/jeweler +1 -0
  12. data/features/generator/gemfile.feature +1 -0
  13. data/features/generator/test.feature +2 -2
  14. data/features/step_definitions/debug_steps.rb +0 -1
  15. data/features/step_definitions/filesystem_steps.rb +2 -3
  16. data/features/step_definitions/generator_steps.rb +44 -66
  17. data/features/step_definitions/task_steps.rb +1 -2
  18. data/features/support/env.rb +22 -9
  19. data/jeweler.gemspec +64 -45
  20. data/lib/jeweler/commands/build_gem.rb +6 -2
  21. data/lib/jeweler/commands/check_dependencies.rb +3 -3
  22. data/lib/jeweler/commands/install_gem.rb +1 -1
  23. data/lib/jeweler/commands/release_gemspec.rb +17 -14
  24. data/lib/jeweler/commands/release_to_git.rb +20 -11
  25. data/lib/jeweler/commands/validate_gemspec.rb +5 -7
  26. data/lib/jeweler/commands/version/base.rb +8 -13
  27. data/lib/jeweler/commands/version/bump_major.rb +1 -3
  28. data/lib/jeweler/commands/version/bump_minor.rb +1 -2
  29. data/lib/jeweler/commands/version/bump_patch.rb +1 -4
  30. data/lib/jeweler/commands/write_gemspec.rb +4 -3
  31. data/lib/jeweler/commands.rb +6 -6
  32. data/lib/jeweler/gemspec_helper.rb +15 -15
  33. data/lib/jeweler/generator/application.rb +5 -10
  34. data/lib/jeweler/generator/bacon_mixin.rb +2 -4
  35. data/lib/jeweler/generator/github_mixin.rb +1 -10
  36. data/lib/jeweler/generator/micronaut_mixin.rb +3 -3
  37. data/lib/jeweler/generator/minitest_mixin.rb +2 -3
  38. data/lib/jeweler/generator/options.rb +16 -25
  39. data/lib/jeweler/generator/rdoc_mixin.rb +1 -1
  40. data/lib/jeweler/generator/riot_mixin.rb +2 -3
  41. data/lib/jeweler/generator/rspec_mixin.rb +2 -3
  42. data/lib/jeweler/generator/shindo_mixin.rb +2 -3
  43. data/lib/jeweler/generator/shoulda_mixin.rb +2 -3
  44. data/lib/jeweler/generator/testspec_mixin.rb +2 -3
  45. data/lib/jeweler/generator/testunit_mixin.rb +1 -3
  46. data/lib/jeweler/generator/yard_mixin.rb +3 -4
  47. data/lib/jeweler/generator.rb +52 -45
  48. data/lib/jeweler/rubyforge_tasks.rb +13 -13
  49. data/lib/jeweler/rubygems_dot_org_tasks.rb +3 -3
  50. data/lib/jeweler/rubygems_tasks.rb +3 -3
  51. data/lib/jeweler/specification.rb +22 -11
  52. data/lib/jeweler/tasks.rb +68 -59
  53. data/lib/jeweler/templates/Gemfile +1 -1
  54. data/lib/jeweler/templates/bacon/flunking.rb +3 -3
  55. data/lib/jeweler/templates/bacon/helper.rb +1 -0
  56. data/lib/jeweler/templates/features/support/env.rb +1 -0
  57. data/lib/jeweler/templates/jeweler_tasks.erb +1 -1
  58. data/lib/jeweler/templates/micronaut/flunking.rb +3 -3
  59. data/lib/jeweler/templates/micronaut/helper.rb +1 -0
  60. data/lib/jeweler/templates/minitest/flunking.rb +1 -1
  61. data/lib/jeweler/templates/minitest/helper.rb +4 -3
  62. data/lib/jeweler/templates/other_tasks.erb +4 -20
  63. data/lib/jeweler/templates/riot/flunking.rb +1 -1
  64. data/lib/jeweler/templates/riot/helper.rb +1 -0
  65. data/lib/jeweler/templates/rspec/flunking.rb +3 -3
  66. data/lib/jeweler/templates/rspec/helper.rb +3 -1
  67. data/lib/jeweler/templates/shindo/flunking.rb +3 -3
  68. data/lib/jeweler/templates/shindo/helper.rb +1 -0
  69. data/lib/jeweler/templates/shoulda/helper.rb +1 -0
  70. data/lib/jeweler/templates/simplecov.erb +16 -0
  71. data/lib/jeweler/templates/testspec/flunking.rb +3 -3
  72. data/lib/jeweler/templates/testspec/helper.rb +1 -1
  73. data/lib/jeweler/templates/testunit/helper.rb +1 -0
  74. data/lib/jeweler/version.rb +3 -3
  75. data/lib/jeweler/version_helper.rb +18 -15
  76. data/lib/jeweler.rb +23 -23
  77. data/test/fixtures/bar/lib/foo_the_ultimate_lib.rb +1 -1
  78. data/test/fixtures/existing-project-with-version-constant/Rakefile +18 -20
  79. data/test/fixtures/existing-project-with-version-constant/existing-project-with-version.gemspec +15 -17
  80. data/test/fixtures/existing-project-with-version-constant/test/existing_project_with_version_test.rb +2 -2
  81. data/test/fixtures/existing-project-with-version-plaintext/Rakefile +17 -19
  82. data/test/fixtures/existing-project-with-version-plaintext/existing-project-with-version.gemspec +15 -17
  83. data/test/fixtures/existing-project-with-version-plaintext/test/existing_project_with_version_test.rb +2 -2
  84. data/test/fixtures/existing-project-with-version-yaml/Rakefile +17 -19
  85. data/test/fixtures/existing-project-with-version-yaml/existing-project-with-version.gemspec +15 -17
  86. data/test/fixtures/existing-project-with-version-yaml/test/existing_project_with_version_test.rb +2 -2
  87. data/test/jeweler/commands/test_build_gem.rb +33 -27
  88. data/test/jeweler/commands/test_install_gem.rb +7 -7
  89. data/test/jeweler/commands/test_release_to_gemcutter.rb +6 -7
  90. data/test/jeweler/commands/test_release_to_git.rb +95 -37
  91. data/test/jeweler/commands/test_release_to_github.rb +161 -97
  92. data/test/jeweler/commands/test_validate_gemspec.rb +4 -6
  93. data/test/jeweler/commands/test_write_gemspec.rb +21 -24
  94. data/test/jeweler/commands/version/test_base.rb +26 -6
  95. data/test/jeweler/commands/version/test_bump_major.rb +1 -5
  96. data/test/jeweler/commands/version/test_bump_minor.rb +1 -2
  97. data/test/jeweler/commands/version/test_bump_patch.rb +1 -3
  98. data/test/jeweler/commands/version/test_write.rb +1 -3
  99. data/test/jeweler/generator/test_application.rb +22 -26
  100. data/test/jeweler/generator/test_options.rb +26 -38
  101. data/test/jeweler/test_gemspec_helper.rb +7 -7
  102. data/test/jeweler/test_generator.rb +31 -33
  103. data/test/jeweler/test_generator_initialization.rb +40 -57
  104. data/test/jeweler/test_generator_mixins.rb +6 -7
  105. data/test/jeweler/test_specification.rb +44 -43
  106. data/test/jeweler/test_tasks.rb +2 -3
  107. data/test/jeweler/test_version_helper.rb +33 -35
  108. data/test/shoulda_macros/jeweler_macros.rb +5 -5
  109. data/test/test_helper.rb +25 -31
  110. data/test/test_jeweler.rb +28 -29
  111. metadata +206 -165
@@ -1,75 +1,78 @@
1
1
  require 'test_helper'
2
+ require 'jeweler/commands/build_gem'
2
3
 
3
4
  class Jeweler
4
5
  module Commands
5
6
  class TestBuildGem < Test::Unit::TestCase
6
-
7
- context "after running without a version" do
7
+ context 'after running without a version' do
8
8
  setup do
9
9
  initialize_build_gem_environment
10
10
  @command.run
11
11
  end
12
12
 
13
- should "check if the gemspec helper has a version" do
14
- assert_received(@gemspec_helper) {|gemspec_helper| gemspec_helper.has_version? }
13
+ should 'check if the gemspec helper has a version' do
14
+ assert_received(@gemspec_helper, &:has_version?)
15
15
  end
16
16
 
17
17
  should "update version of gemspec helper if the gemspec doesn't have a version" do
18
- assert_received(@gemspec_helper) {|gemspec_helper| gemspec_helper.update_version(@version_helper)}
18
+ assert_received(@gemspec_helper) { |gemspec_helper| gemspec_helper.update_version(@version_helper) }
19
19
  end
20
20
 
21
21
  should "call gemspec helper's parse" do
22
- assert_received(@gemspec_helper) {|gemspec_helper| gemspec_helper.parse }
22
+ assert_received(@gemspec_helper, &:parse)
23
23
  end
24
24
 
25
- should "build from parsed gemspec" do
26
- assert_received(Gem::Builder) {|builder_class| builder_class.new(@gemspec) }
27
- assert_received(@builder) {|builder| builder.build }
25
+ should 'build from parsed gemspec' do
26
+ if Gem::Version.new(`gem -v`) >= Gem::Version.new('2.0.0.a')
27
+ assert_received(Gem::Package) { |builder_class| builder_class.build(@gemspec) }
28
+ else
29
+ assert_received(Gem::Builder) { |builder_class| builder_class.new(@gemspec) }
30
+ assert_received(@builder, &:build)
31
+ end
28
32
  end
29
33
 
30
34
  should 'make package directory' do
31
- assert_received(@file_utils) {|file_utils| file_utils.mkdir_p './pkg'}
35
+ assert_received(@file_utils) { |file_utils| file_utils.mkdir_p './pkg' }
32
36
  end
33
37
 
34
38
  should 'move built gem into package directory' do
35
- assert_received(@file_utils) {|file_utils| file_utils.mv './zomg-1.2.3.gem', './pkg'}
39
+ assert_received(@file_utils) { |file_utils| file_utils.mv './zomg-1.2.3.gem', './pkg' }
36
40
  end
37
41
  end
38
-
42
+
39
43
  context 'after running with a version' do
40
44
  setup do
41
45
  initialize_build_gem_environment true
42
46
  @command.run
43
47
  end
44
-
45
- should "check if the gemspec helper has a version" do
46
- assert_received(@gemspec_helper) {|gemspec_helper| gemspec_helper.has_version? }
48
+
49
+ should 'check if the gemspec helper has a version' do
50
+ assert_received(@gemspec_helper, &:has_version?)
47
51
  end
48
-
52
+
49
53
  should "update version of gemspec helper if the gemspec doesn't have a version" do
50
- assert_received(@gemspec_helper) {|gemspec_helper| gemspec_helper.update_version(@version_helper).never }
54
+ assert_received(@gemspec_helper) { |gemspec_helper| gemspec_helper.update_version(@version_helper).never }
51
55
  end
52
-
53
56
  end
54
57
 
55
- build_command_context "build for jeweler" do
58
+ build_command_context 'build for jeweler' do
56
59
  setup do
57
60
  @command = Jeweler::Commands::BuildGem.build_for(@jeweler)
58
61
  end
59
62
 
60
- should "assign base_dir" do
63
+ should 'assign base_dir' do
61
64
  assert_same @base_dir, @jeweler.base_dir
62
65
  end
63
66
 
64
- should "assign gemspec_helper" do
67
+ should 'assign gemspec_helper' do
65
68
  assert_same @gemspec_helper, @jeweler.gemspec_helper
66
69
  end
67
70
 
68
- should "return BuildGem" do
71
+ should 'return BuildGem' do
69
72
  assert_kind_of Jeweler::Commands::BuildGem, @command
70
73
  end
71
74
  end
72
-
75
+
73
76
  def initialize_build_gem_environment(has_version = false)
74
77
  @gemspec = Object.new
75
78
  stub(@gemspec).file_name { 'zomg-1.2.3.gem' }
@@ -79,11 +82,15 @@ class Jeweler
79
82
  stub(@gemspec_helper).update_version
80
83
  stub(@gemspec_helper).has_version? { has_version }
81
84
 
82
- @version_helper = "Jeweler::VersionHelper"
85
+ @version_helper = 'Jeweler::VersionHelper'
83
86
 
84
87
  @builder = Object.new
85
- stub(Gem::Builder).new { @builder }
86
- stub(@builder).build { 'zomg-1.2.3.gem' }
88
+ if Gem::Version.new(`gem -v`) >= Gem::Version.new('2.0.0.a')
89
+ stub(Gem::Package).build { 'zomg-1.2.3.gem' }
90
+ else
91
+ stub(Gem::Builder).new { @builder }
92
+ stub(@builder).build { 'zomg-1.2.3.gem' }
93
+ end
87
94
 
88
95
  @file_utils = Object.new
89
96
  stub(@file_utils).mkdir_p './pkg'
@@ -97,7 +104,6 @@ class Jeweler
97
104
  @command.gemspec_helper = @gemspec_helper
98
105
  @command.version_helper = @version_helper
99
106
  end
100
-
101
107
  end
102
108
  end
103
109
  end
@@ -3,30 +3,30 @@ require 'test_helper'
3
3
  class Jeweler
4
4
  module Commands
5
5
  class TestInstallGem < Test::Unit::TestCase
6
- rubyforge_command_context "running" do
6
+ rubyforge_command_context 'running' do
7
7
  setup do
8
- stub(@gemspec_helper).gem_path { 'pkg/zomg-1.1.1.gem' }
8
+ stub(@gemspec_helper).gem_path { 'pkg/zomg-1.1.1.gem' }
9
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
- should "call sh with gem install" do
16
- assert_received(@command) {|command| command.sh 'ruby -S gem install pkg/zomg-1.1.1.gem' }
15
+ should 'call sh with gem install' do
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
 
20
- build_command_context "build for jeweler" do
20
+ build_command_context 'build for jeweler' do
21
21
  setup do
22
22
  @command = Jeweler::Commands::InstallGem.build_for(@jeweler)
23
23
  end
24
24
 
25
- should "assign gemspec helper" do
25
+ should 'assign gemspec helper' do
26
26
  assert_equal @gemspec_helper, @command.gemspec_helper
27
27
  end
28
28
 
29
- should "assign output" do
29
+ should 'assign output' do
30
30
  assert_equal @output, @command.output
31
31
  end
32
32
  end
@@ -7,33 +7,32 @@ class Jeweler
7
7
  Jeweler::Commands::ReleaseToRubygems.new
8
8
  end
9
9
 
10
- gemcutter_command_context "rubyforge_project is defined in gemspec and package exists on rubyforge" do
10
+ gemcutter_command_context 'rubyforge_project is defined in gemspec and package exists on rubyforge' do
11
11
  setup do
12
- stub(@gemspec_helper).gem_path {'pkg/zomg-1.2.3.gem'}
12
+ stub(@gemspec_helper).gem_path { 'pkg/zomg-1.2.3.gem' }
13
13
  stub(@command).sh
14
14
  @command.run
15
15
  end
16
16
 
17
- should "push to rubygems" 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
21
21
  end
22
22
 
23
- build_command_context "build for jeweler" do
23
+ build_command_context 'build for jeweler' do
24
24
  setup do
25
25
  @command = Jeweler::Commands::ReleaseToRubygems.build_for(@jeweler)
26
26
  end
27
27
 
28
- should "assign gemspec helper" do
28
+ should 'assign gemspec helper' do
29
29
  assert_equal @gemspec_helper, @command.gemspec_helper
30
30
  end
31
31
 
32
- should "assign output" do
32
+ should 'assign output' do
33
33
  assert_equal @output, @command.output
34
34
  end
35
35
  end
36
-
37
36
  end
38
37
  end
39
38
  end
@@ -3,9 +3,8 @@ require 'test_helper'
3
3
  class Jeweler
4
4
  module Commands
5
5
  class TestReleaseToGit < Test::Unit::TestCase
6
-
7
- rubyforge_command_context "running" do
8
- context "happily" do
6
+ rubyforge_command_context 'running' do
7
+ context 'happily' do
9
8
  setup do
10
9
  stub(@command).clean_staging_area? { true }
11
10
 
@@ -22,35 +21,100 @@ class Jeweler
22
21
  @command.run
23
22
  end
24
23
 
25
- should "checkout master" do
26
- assert_received(@repo) {|repo| repo.checkout('master') }
24
+ should 'checkout master' do
25
+ assert_received(@repo) { |repo| repo.checkout('master') }
26
+ end
27
+
28
+ should 'push' do
29
+ assert_received(@repo) { |repo| repo.push('origin', 'master:master') }
30
+ end
31
+ end
32
+
33
+ context 'happily with different remote, local branch and remote branch' do
34
+ setup do
35
+ stub(@command).clean_staging_area? { true }
36
+ stub(@command).release_tag { 'v1.2.0' }
37
+
38
+ stub(@repo).checkout(anything)
39
+ stub(@repo) do
40
+ add_tag(anything)
41
+ push(anything, anything)
42
+ end
43
+
44
+ stub(@repo).push
45
+
46
+ stub(@command).release_not_tagged? { true }
47
+
48
+ @command.run(remote: 'upstream', local_branch: 'feature', remote_branch: 'v1')
49
+ end
50
+
51
+ should 'checkout master' do
52
+ assert_received(@repo) { |repo| repo.checkout('feature') }
27
53
  end
28
54
 
29
- should "push" do
30
- assert_received(@repo) {|repo| repo.push }
55
+ should 'tag version' do
56
+ assert_received(@repo) { |repo| repo.add_tag('v1.2.0') }
31
57
  end
32
58
 
59
+ should 'push' do
60
+ assert_received(@repo) { |repo| repo.push('upstream', 'feature:v1') }
61
+ end
33
62
  end
34
63
 
35
- context "with an unclean staging area" do
64
+ context 'happily with different branch' do
65
+ setup do
66
+ stub(@command).clean_staging_area? { true }
67
+ stub(@command).release_tag { 'v3.2.0' }
68
+
69
+ stub(@repo).checkout(anything)
70
+ stub(@repo) do
71
+ add_tag(anything)
72
+ push(anything, anything)
73
+ end
74
+
75
+ stub(@repo).push
76
+
77
+ stub(@command).release_not_tagged? { true }
78
+
79
+ @command.run(branch: 'v3')
80
+ end
81
+
82
+ should 'checkout master' do
83
+ assert_received(@repo) { |repo| repo.checkout('v3') }
84
+ end
85
+
86
+ should 'tag version' do
87
+ assert_received(@repo) { |repo| repo.add_tag('v3.2.0') }
88
+ end
89
+
90
+ should 'push' do
91
+ assert_received(@repo) { |repo| repo.push('origin', 'v3:v3') }
92
+ end
93
+ end
94
+
95
+ context 'with an unclean staging area' do
36
96
  setup do
37
97
  stub(@command).clean_staging_area? { false }
38
98
  stub(@command).system
39
99
  end
40
100
 
41
101
  should 'raise error' do
42
- assert_raises RuntimeError, /try commiting/i do
102
+ assert_raises RuntimeError, 'Unclean staging area! Be sure to commit or .gitignore everything first. See `git status` above.' do
43
103
  @command.run
44
104
  end
45
105
  end
46
106
 
47
107
  should 'display git status' do
48
- @command.run rescue nil
49
- assert_received(@command) {|command| command.system("git status") }
108
+ begin
109
+ @command.run
110
+ rescue
111
+ nil
112
+ end
113
+ assert_received(@command) { |command| command.system('git status') }
50
114
  end
51
115
  end
52
116
 
53
- context "with a release already tagged" do
117
+ context 'with a release already tagged' do
54
118
  setup do
55
119
  stub(@command).clean_staging_area? { true }
56
120
 
@@ -63,51 +127,48 @@ class Jeweler
63
127
  @command.run
64
128
  end
65
129
 
66
- should "checkout master" do
67
- assert_received(@repo) {|repo| repo.checkout('master') }
130
+ should 'checkout master' do
131
+ assert_received(@repo) { |repo| repo.checkout('master') }
68
132
  end
69
133
 
70
- should "push" do
71
- assert_received(@repo) {|repo| repo.push }
134
+ should 'push' do
135
+ assert_received(@repo) { |repo| repo.push('origin', 'master:master') }
72
136
  end
73
-
74
137
  end
75
-
76
138
  end
77
139
 
78
-
79
- build_command_context "building from jeweler" do
140
+ build_command_context 'building from jeweler' do
80
141
  setup do
81
142
  @command = Jeweler::Commands::ReleaseToGit.build_for(@jeweler)
82
143
  end
83
144
 
84
- should "assign gemspec" do
145
+ should 'assign gemspec' do
85
146
  assert_same @gemspec, @command.gemspec
86
147
  end
87
148
 
88
- should "assign version" do
149
+ should 'assign version' do
89
150
  assert_same @version, @command.version
90
151
  end
91
152
 
92
- should "assign repo" do
153
+ should 'assign repo' do
93
154
  assert_same @repo, @command.repo
94
155
  end
95
156
 
96
- should "assign output" do
157
+ should 'assign output' do
97
158
  assert_same @output, @command.output
98
159
  end
99
160
 
100
- should "assign gemspec_helper" do
161
+ should 'assign gemspec_helper' do
101
162
  assert_same @gemspec_helper, @command.gemspec_helper
102
163
  end
103
164
 
104
- should "assign base_dir" do
165
+ should 'assign base_dir' do
105
166
  assert_same @base_dir, @command.base_dir
106
167
  end
107
168
  end
108
169
 
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
170
+ # FIXME: this code had its ruby-git stuff replaced with `` and system, which is much harder to test, so re-enable these someday
171
+ # context "clean_staging_area?" do
111
172
 
112
173
  # should "be false if there added files" do
113
174
  # repo = build_repo :added => %w(README)
@@ -143,9 +204,9 @@ class Jeweler
143
204
 
144
205
  # assert command.clean_staging_area?
145
206
  # end
146
- #end
207
+ # end
147
208
 
148
- context "release_tagged? when no tag exists" do
209
+ context 'release_tagged? when no tag exists' do
149
210
  setup do
150
211
  @repo = Object.new
151
212
  stub(@repo).tag('v1.2.3') { raise Git::GitTagNameDoesNotExist, tag }
@@ -158,13 +219,12 @@ class Jeweler
158
219
  @command.version = '1.2.3'
159
220
  end
160
221
 
161
- should_eventually "be true" do
222
+ should_eventually 'be true' do
162
223
  assert @command.release_not_tagged?
163
224
  end
164
-
165
225
  end
166
226
 
167
- context "release_tagged? when tag exists" do
227
+ context 'release_tagged? when tag exists' do
168
228
  setup do
169
229
  @repo = Object.new
170
230
  stub(@repo) do
@@ -179,10 +239,9 @@ class Jeweler
179
239
  @command.version = '1.2.3'
180
240
  end
181
241
 
182
- should_eventually "be false" do
242
+ should_eventually 'be false' do
183
243
  assert @command.release_not_tagged?
184
244
  end
185
-
186
245
  end
187
246
 
188
247
  def build_repo(options = {})
@@ -193,7 +252,7 @@ class Jeweler
193
252
  end
194
253
 
195
254
  def build_status(options = {})
196
- options = {:added => [], :deleted => [], :changed => []}.merge(options)
255
+ options = { added: [], deleted: [], changed: [] }.merge(options)
197
256
 
198
257
  status = Object.new
199
258
  stub(status) do
@@ -201,7 +260,6 @@ class Jeweler
201
260
  deleted { options[:deleted] }
202
261
  changed { options[:changed] }
203
262
  end
204
-
205
263
  end
206
264
  end
207
265
  end