jeweler 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. data/ChangeLog.markdown +64 -0
  2. data/LICENSE +20 -0
  3. data/README.markdown +164 -0
  4. data/Rakefile +89 -0
  5. data/TODO +11 -0
  6. data/VERSION.yml +4 -0
  7. data/bin/jeweler +8 -0
  8. data/lib/jeweler.rb +154 -0
  9. data/lib/jeweler/commands.rb +12 -0
  10. data/lib/jeweler/commands/build_gem.rb +31 -0
  11. data/lib/jeweler/commands/install_gem.rb +26 -0
  12. data/lib/jeweler/commands/release.rb +59 -0
  13. data/lib/jeweler/commands/release_to_rubyforge.rb +51 -0
  14. data/lib/jeweler/commands/setup_rubyforge.rb +38 -0
  15. data/lib/jeweler/commands/validate_gemspec.rb +30 -0
  16. data/lib/jeweler/commands/version/base.rb +41 -0
  17. data/lib/jeweler/commands/version/bump_major.rb +13 -0
  18. data/lib/jeweler/commands/version/bump_minor.rb +12 -0
  19. data/lib/jeweler/commands/version/bump_patch.rb +14 -0
  20. data/lib/jeweler/commands/version/write.rb +12 -0
  21. data/lib/jeweler/commands/write_gemspec.rb +39 -0
  22. data/lib/jeweler/errors.rb +20 -0
  23. data/lib/jeweler/gemspec_helper.rb +51 -0
  24. data/lib/jeweler/generator.rb +347 -0
  25. data/lib/jeweler/generator/application.rb +45 -0
  26. data/lib/jeweler/generator/options.rb +68 -0
  27. data/lib/jeweler/tasks.rb +119 -0
  28. data/lib/jeweler/templates/.document +5 -0
  29. data/lib/jeweler/templates/.gitignore +5 -0
  30. data/lib/jeweler/templates/LICENSE +20 -0
  31. data/lib/jeweler/templates/README.rdoc +7 -0
  32. data/lib/jeweler/templates/Rakefile +125 -0
  33. data/lib/jeweler/templates/bacon/flunking.rb +7 -0
  34. data/lib/jeweler/templates/bacon/helper.rb +8 -0
  35. data/lib/jeweler/templates/features/default.feature +9 -0
  36. data/lib/jeweler/templates/features/support/env.rb +11 -0
  37. data/lib/jeweler/templates/micronaut/flunking.rb +7 -0
  38. data/lib/jeweler/templates/micronaut/helper.rb +17 -0
  39. data/lib/jeweler/templates/minitest/flunking.rb +7 -0
  40. data/lib/jeweler/templates/minitest/helper.rb +11 -0
  41. data/lib/jeweler/templates/rspec/flunking.rb +7 -0
  42. data/lib/jeweler/templates/rspec/helper.rb +9 -0
  43. data/lib/jeweler/templates/shoulda/flunking.rb +7 -0
  44. data/lib/jeweler/templates/shoulda/helper.rb +10 -0
  45. data/lib/jeweler/templates/testunit/flunking.rb +7 -0
  46. data/lib/jeweler/templates/testunit/helper.rb +9 -0
  47. data/lib/jeweler/version_helper.rb +83 -0
  48. data/test/fixtures/bar/VERSION.yml +4 -0
  49. data/test/fixtures/existing-project-with-version/LICENSE +20 -0
  50. data/test/fixtures/existing-project-with-version/README.rdoc +7 -0
  51. data/test/fixtures/existing-project-with-version/Rakefile +82 -0
  52. data/test/fixtures/existing-project-with-version/VERSION.yml +4 -0
  53. data/test/fixtures/existing-project-with-version/existing-project-with-version.gemspec +29 -0
  54. data/test/fixtures/existing-project-with-version/lib/existing_project_with_version.rb +0 -0
  55. data/test/fixtures/existing-project-with-version/test/existing_project_with_version_test.rb +7 -0
  56. data/test/fixtures/existing-project-with-version/test/test_helper.rb +10 -0
  57. data/test/geminstaller.yml +12 -0
  58. data/test/generators/initialization_test.rb +146 -0
  59. data/test/jeweler/commands/test_build_gem.rb +72 -0
  60. data/test/jeweler/commands/test_install_gem.rb +21 -0
  61. data/test/jeweler/commands/test_release.rb +180 -0
  62. data/test/jeweler/commands/test_release_to_rubyforge.rb +157 -0
  63. data/test/jeweler/commands/test_setup_rubyforge.rb +88 -0
  64. data/test/jeweler/commands/test_validate_gemspec.rb +27 -0
  65. data/test/jeweler/commands/test_write_gemspec.rb +92 -0
  66. data/test/jeweler/commands/version/test_base.rb +32 -0
  67. data/test/jeweler/commands/version/test_bump_major.rb +22 -0
  68. data/test/jeweler/commands/version/test_bump_minor.rb +19 -0
  69. data/test/jeweler/commands/version/test_bump_patch.rb +20 -0
  70. data/test/jeweler/commands/version/test_write.rb +23 -0
  71. data/test/shoulda_macros/jeweler_macros.rb +35 -0
  72. data/test/test_application.rb +113 -0
  73. data/test/test_gemspec_helper.rb +36 -0
  74. data/test/test_generator.rb +183 -0
  75. data/test/test_helper.rb +118 -0
  76. data/test/test_jeweler.rb +177 -0
  77. data/test/test_options.rb +96 -0
  78. data/test/test_tasks.rb +41 -0
  79. data/test/test_version_helper.rb +115 -0
  80. data/test/version_tmp/VERSION.yml +4 -0
  81. metadata +171 -0
@@ -0,0 +1,21 @@
1
+ require 'test_helper'
2
+
3
+ class Jeweler
4
+ module Commands
5
+ class TestInstallGem < Test::Unit::TestCase
6
+ build_command_context "build for jeweler" do
7
+ setup do
8
+ @command = Jeweler::Commands::InstallGem.build_for(@jeweler)
9
+ end
10
+
11
+ should "assign gemspec helper" do
12
+ assert_equal @gemspec_helper, @command.gemspec_helper
13
+ end
14
+
15
+ should "assign output" do
16
+ assert_equal @output, @command.output
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,180 @@
1
+ require 'test_helper'
2
+
3
+ class Jeweler
4
+ module Commands
5
+ class TestRelease < Test::Unit::TestCase
6
+
7
+ context "with added files" do
8
+ setup do
9
+ @repo = Object.new
10
+ stub(@repo).checkout(anything)
11
+
12
+ status = Object.new
13
+ stub(status).added { ['README'] }
14
+ stub(status).deleted { [] }
15
+ stub(status).changed { [] }
16
+ stub(@repo).status { status }
17
+
18
+ @command = Jeweler::Commands::Release.new
19
+ @command.output = @output
20
+ @command.repo = @repo
21
+ @command.gemspec_helper = @gemspec_helper
22
+ @command.version = '1.2.3'
23
+ end
24
+
25
+ should 'raise error' do
26
+ assert_raises RuntimeError, /try commiting/i do
27
+ @command.run
28
+ end
29
+ end
30
+ end
31
+
32
+ context "with deleted files" do
33
+ setup do
34
+ @repo = Object.new
35
+ stub(@repo).checkout(anything)
36
+
37
+ status = Object.new
38
+ stub(status).added { [] }
39
+ stub(status).deleted { ['README'] }
40
+ stub(status).changed { [] }
41
+ stub(@repo).status { status }
42
+
43
+ @command = Jeweler::Commands::Release.new
44
+ @command.output = @output
45
+ @command.repo = @repo
46
+ @command.gemspec_helper = @gemspec_helper
47
+ @command.version = '1.2.3'
48
+ @command.base_dir = '.'
49
+ end
50
+
51
+ should 'raise error' do
52
+ assert_raises RuntimeError, /try commiting/i do
53
+ @command.run
54
+ end
55
+ end
56
+ end
57
+
58
+ context "with changed files" do
59
+ setup do
60
+ @repo = Object.new
61
+ stub(@repo).checkout(anything)
62
+
63
+ status = Object.new
64
+ stub(status).added { [] }
65
+ stub(status).deleted { [] }
66
+ stub(status).changed { ['README'] }
67
+ stub(@repo).status { status }
68
+
69
+ @command = Jeweler::Commands::Release.new
70
+ @command.output = @output
71
+ @command.repo = @repo
72
+ @command.gemspec_helper = @gemspec_helper
73
+ @command.version = '1.2.3'
74
+ end
75
+
76
+ should 'raise error' do
77
+ assert_raises RuntimeError, /try commiting/i do
78
+ @command.run
79
+ end
80
+ end
81
+ end
82
+
83
+ context "after running without pending changes" do
84
+ setup do
85
+ @repo = Object.new
86
+ stub(@repo).checkout(anything)
87
+ stub(@repo).add(anything)
88
+ stub(@repo).commit(anything)
89
+ stub(@repo).push
90
+ stub(@repo).push(anything)
91
+ stub(@repo).add_tag(anything)
92
+
93
+ @gemspec_helper = Object.new
94
+ stub(@gemspec_helper).write
95
+ stub(@gemspec_helper).path {'zomg.gemspec'}
96
+ stub(@gemspec_helper).update_version('1.2.3')
97
+
98
+ status = Object.new
99
+ stub(status).added { [] }
100
+ stub(status).deleted { [] }
101
+ stub(status).changed { [] }
102
+ stub(@repo).status { status }
103
+
104
+ @output = StringIO.new
105
+
106
+ @command = Jeweler::Commands::Release.new
107
+ @command.output = @output
108
+ @command.repo = @repo
109
+ @command.gemspec_helper = @gemspec_helper
110
+ @command.version = '1.2.3'
111
+
112
+ @command.run
113
+ end
114
+
115
+ should "checkout master" do
116
+ assert_received(@repo) {|repo| repo.checkout('master') }
117
+ end
118
+
119
+ should "refresh gemspec version" do
120
+ assert_received(@gemspec_helper) {|gemspec_helper| gemspec_helper.update_version('1.2.3') }
121
+ end
122
+
123
+ should "write gemspec" do
124
+ assert_received(@gemspec_helper) {|gemspec_helper| gemspec_helper.write }
125
+
126
+ end
127
+
128
+ should "add gemspec to repository" do
129
+ assert_received(@repo) {|repo| repo.add('zomg.gemspec') }
130
+ end
131
+
132
+ should "commit with commit message including version" do
133
+ assert_received(@repo) {|repo| repo.commit("Regenerated gemspec for version 1.2.3") }
134
+ end
135
+
136
+ should "push repository" do
137
+ assert_received(@repo) {|repo| repo.push }
138
+ end
139
+
140
+ should "tag release" do
141
+ assert_received(@repo) {|repo| repo.add_tag("v1.2.3")}
142
+ end
143
+
144
+ should "push tag to repository" do
145
+ assert_received(@repo) {|repo| repo.push('origin', 'v1.2.3')}
146
+ end
147
+ end
148
+
149
+ build_command_context "building from jeweler" do
150
+ setup do
151
+ @command = Jeweler::Commands::Release.build_for(@jeweler)
152
+ end
153
+
154
+ should "assign gemspec" do
155
+ assert_same @gemspec, @command.gemspec
156
+ end
157
+
158
+ should "assign version" do
159
+ assert_same @version, @command.version
160
+ end
161
+
162
+ should "assign repo" do
163
+ assert_same @repo, @command.repo
164
+ end
165
+
166
+ should "assign output" do
167
+ assert_same @output, @command.output
168
+ end
169
+
170
+ should "assign gemspec_helper" do
171
+ assert_same @gemspec_helper, @command.gemspec_helper
172
+ end
173
+
174
+ should "assign base_dir" do
175
+ assert_same @base_dir, @command.base_dir
176
+ end
177
+ end
178
+ end
179
+ end
180
+ end
@@ -0,0 +1,157 @@
1
+ require 'test_helper'
2
+
3
+ class Jeweler
4
+ module Commands
5
+ class TestReleaseToRubyforge < Test::Unit::TestCase
6
+ def self.subject
7
+ Jeweler::Commands::ReleaseToRubyforge.new
8
+ end
9
+
10
+ rubyforge_command_context "rubyforge_project is defined in gemspec and package exists on rubyforge" do
11
+ setup do
12
+ stub(@rubyforge).configure
13
+ stub(@rubyforge).login
14
+ stub(@rubyforge).add_release("MyRubyForgeProjectName", "zomg", "1.2.3", "pkg/zomg-1.2.3.gem")
15
+
16
+ stub(@gemspec).description {"The zomg gem rocks."}
17
+ stub(@gemspec).rubyforge_project {"MyRubyForgeProjectName"}
18
+ stub(@gemspec).name {"zomg"}
19
+
20
+ stub(@gemspec_helper).write
21
+ stub(@gemspec_helper).gem_path {'pkg/zomg-1.2.3.gem'}
22
+ stub(@gemspec_helper).update_version('1.2.3')
23
+
24
+ @command.version = '1.2.3'
25
+
26
+ @command.run
27
+ end
28
+
29
+ should "configure" do
30
+ assert_received(@rubyforge) {|rubyforge| rubyforge.configure }
31
+ end
32
+
33
+ should "login" do
34
+ assert_received(@rubyforge) {|rubyforge| rubyforge.login }
35
+ end
36
+
37
+ should "set release notes" do
38
+ assert_equal "The zomg gem rocks.", @rubyforge.userconfig["release_notes"]
39
+ end
40
+
41
+ should "set preformatted to true" do
42
+ assert_equal true, @rubyforge.userconfig['preformatted']
43
+ end
44
+
45
+ should "add release" do
46
+ assert_received(@rubyforge) {|rubyforge| rubyforge.add_release("MyRubyForgeProjectName", "zomg", "1.2.3", "pkg/zomg-1.2.3.gem") }
47
+ end
48
+ end
49
+
50
+ rubyforge_command_context "rubyforge_project is defined in gemspec and package does not exist on rubyforge" do
51
+ setup do
52
+ stub(@rubyforge).configure
53
+ stub(@rubyforge).login
54
+ stub(@rubyforge).scrape_config
55
+ stub(@rubyforge).add_release("MyRubyForgeProjectName", "zomg", "1.2.3", "pkg/zomg-1.2.3.gem") {
56
+ raise "no <package_id> configured for <zomg>"
57
+ }
58
+
59
+ stub(@gemspec).description {"The zomg gem rocks."}
60
+ stub(@gemspec).rubyforge_project {"MyRubyForgeProjectName"}
61
+ stub(@gemspec).name {"zomg"}
62
+
63
+ stub(@gemspec_helper).write
64
+ stub(@gemspec_helper).gem_path {'pkg/zomg-1.2.3.gem'}
65
+ stub(@gemspec_helper).update_version('1.2.3')
66
+
67
+ @command.version = '1.2.3'
68
+ end
69
+
70
+ should "raise MissingRubyForgePackageError" do
71
+ assert_raises Jeweler::MissingRubyForgePackageError do
72
+ @command.run
73
+ end
74
+ end
75
+ end
76
+
77
+ rubyforge_command_context "rubyforge_project is not defined in gemspec" do
78
+ setup do
79
+ stub(@rubyforge).configure
80
+ stub(@rubyforge).login
81
+ stub(@rubyforge).add_release(nil, "zomg", "1.2.3", "pkg/zomg-1.2.3.gem")
82
+
83
+ stub(@gemspec).description {"The zomg gem rocks."}
84
+ stub(@gemspec).rubyforge_project { nil }
85
+ stub(@gemspec).name {"zomg"}
86
+
87
+ stub(@gemspec_helper).write
88
+ stub(@gemspec_helper).gem_path {'pkg/zomg-1.2.3.gem'}
89
+ stub(@gemspec_helper).update_version('1.2.3')
90
+
91
+ @command.version = '1.2.3'
92
+ end
93
+
94
+ should "raise NoRubyForgeProjectConfigured" do
95
+ assert_raises Jeweler::NoRubyForgeProjectInGemspecError do
96
+ @command.run
97
+ end
98
+ end
99
+ end
100
+
101
+ rubyforge_command_context "after running when rubyforge_project is not defined in ~/.rubyforge/auto_config.yml" do
102
+ setup do
103
+ stub(@rubyforge).configure
104
+ stub(@rubyforge).login
105
+ stub(@rubyforge).add_release("some_project_that_doesnt_exist", "zomg", "1.2.3", "pkg/zomg-1.2.3.gem") do
106
+ raise RuntimeError, "no <group_id> configured for <some_project_that_doesnt_exist>"
107
+ end
108
+
109
+ @rubyforge.autoconfig['package_ids'] = { 'zomg' => 1234 }
110
+
111
+ stub(@gemspec).description {"The zomg gem rocks."}
112
+ stub(@gemspec).rubyforge_project { "some_project_that_doesnt_exist" }
113
+ stub(@gemspec).name {"zomg"}
114
+
115
+ stub(@gemspec_helper).write
116
+ stub(@gemspec_helper).gem_path {'pkg/zomg-1.2.3.gem'}
117
+ stub(@gemspec_helper).update_version('1.2.3')
118
+
119
+ @command.version = '1.2.3'
120
+ end
121
+
122
+ should "raise RubyForgeProjectNotConfiguredError" do
123
+ assert_raises RubyForgeProjectNotConfiguredError do
124
+ @command.run
125
+ end
126
+ end
127
+ end
128
+
129
+ build_command_context "build for jeweler" do
130
+ setup do
131
+ @command = Jeweler::Commands::ReleaseToRubyforge.build_for(@jeweler)
132
+ end
133
+
134
+ should "assign gemspec helper" do
135
+ assert_equal @gemspec_helper, @command.gemspec_helper
136
+ end
137
+
138
+ should "assign gemspec" do
139
+ assert_equal @gemspec, @command.gemspec
140
+ end
141
+
142
+ should "assign version" do
143
+ assert_equal @version, @command.version
144
+ end
145
+
146
+ should "assign output" do
147
+ assert_equal @output, @command.output
148
+ end
149
+
150
+ should "assign rubyforge" do
151
+ assert_equal @rubyforge, @command.rubyforge
152
+ end
153
+ end
154
+
155
+ end
156
+ end
157
+ end
@@ -0,0 +1,88 @@
1
+ require 'test_helper'
2
+
3
+ class Jeweler
4
+ module Commands
5
+ class TestSetupRubyforge < Test::Unit::TestCase
6
+ def self.subject
7
+ Jeweler::Commands::SetupRubyforge.new
8
+ end
9
+
10
+ rubyforge_command_context "rubyforge_project is defined in gemspec and package exists on rubyforge" do
11
+ setup do
12
+ stub(@rubyforge).configure
13
+ stub(@rubyforge).login
14
+ stub(@rubyforge).create_package('myproject', 'zomg')
15
+
16
+ stub(@gemspec).name { 'zomg' }
17
+ stub(@gemspec).rubyforge_project { 'myproject' }
18
+
19
+ @command.run
20
+ end
21
+
22
+ should "configure rubyforge" do
23
+ assert_received(@rubyforge) {|rubyforge| rubyforge.configure}
24
+ end
25
+
26
+ should "login to rubyforge" do
27
+ assert_received(@rubyforge) {|rubyforge| rubyforge.login}
28
+ end
29
+
30
+ should "create zomg package to myproject on rubyforge" do
31
+ assert_received(@rubyforge) {|rubyforge| rubyforge.create_package('myproject', 'zomg') }
32
+ end
33
+ end
34
+
35
+ rubyforge_command_context "rubyforge_project not configured" do
36
+ setup do
37
+ stub(@gemspec).name { 'zomg' }
38
+ stub(@gemspec).rubyforge_project { nil }
39
+ end
40
+
41
+ should "raise NoRubyForgeProjectConfigured" do
42
+ assert_raises Jeweler::NoRubyForgeProjectInGemspecError do
43
+ @command.run
44
+ end
45
+ end
46
+ end
47
+
48
+ rubyforge_command_context "rubyforge project doesn't exist or not setup in ~/.rubyforge/autoconfig.yml" do
49
+ setup do
50
+ stub(@rubyforge).configure
51
+ stub(@rubyforge).login
52
+ stub(@rubyforge).create_package('some_project_that_doesnt_exist', 'zomg')do
53
+ raise RuntimeError, "no <group_id> configured for <some_project_that_doesnt_exist>"
54
+ end
55
+
56
+ stub(@gemspec).name { 'zomg' }
57
+ stub(@gemspec).rubyforge_project { 'some_project_that_doesnt_exist' }
58
+ end
59
+
60
+ should "raise RubyForgeProjectNotConfiguredError" do
61
+ assert_raises RubyForgeProjectNotConfiguredError do
62
+ @command.run
63
+ end
64
+ end
65
+
66
+ end
67
+
68
+ build_command_context "build for jeweler" do
69
+ setup do
70
+ @command = Jeweler::Commands::SetupRubyforge.build_for(@jeweler)
71
+ end
72
+
73
+ should "assign gemspec" do
74
+ assert_equal @gemspec, @command.gemspec
75
+ end
76
+
77
+ should "assign output" do
78
+ assert_equal @output, @command.output
79
+ end
80
+
81
+ should "assign rubyforge" do
82
+ assert_equal @rubyforge, @command.rubyforge
83
+ end
84
+ end
85
+
86
+ end
87
+ end
88
+ end