mcornick-jeweler 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -0
- data/ChangeLog.markdown +111 -0
- data/LICENSE +20 -0
- data/README.markdown +185 -0
- data/ROADMAP +12 -0
- data/Rakefile +103 -0
- data/VERSION.yml +4 -0
- data/bin/jeweler +8 -0
- data/features/generator/cucumber.feature +83 -0
- data/features/generator/directory_layout.feature +76 -0
- data/features/generator/dotdocument.feature +14 -0
- data/features/generator/env_options.feature +9 -0
- data/features/generator/git.feature +94 -0
- data/features/generator/license.feature +11 -0
- data/features/generator/rakefile.feature +151 -0
- data/features/generator/readme.feature +12 -0
- data/features/generator/test.feature +41 -0
- data/features/generator/test_helper.feature +49 -0
- data/features/placeholder.feature +5 -0
- data/features/step_definitions/debug_steps.rb +6 -0
- data/features/step_definitions/filesystem_steps.rb +68 -0
- data/features/step_definitions/generator_steps.rb +284 -0
- data/features/step_definitions/task_steps.rb +6 -0
- data/features/support/env.rb +29 -0
- data/features/tasks/build_gem.feature +9 -0
- data/features/tasks/version.feature +24 -0
- data/features/tasks/version_bumping.feature +33 -0
- data/jeweler.gemspec +225 -0
- data/lib/jeweler.rb +153 -0
- data/lib/jeweler/commands.rb +14 -0
- data/lib/jeweler/commands/build_gem.rb +31 -0
- data/lib/jeweler/commands/check_dependencies.rb +52 -0
- data/lib/jeweler/commands/install_gem.rb +40 -0
- data/lib/jeweler/commands/release.rb +86 -0
- data/lib/jeweler/commands/release_to_rubyforge.rb +51 -0
- data/lib/jeweler/commands/setup_rubyforge.rb +57 -0
- data/lib/jeweler/commands/validate_gemspec.rb +30 -0
- data/lib/jeweler/commands/version/base.rb +41 -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/errors.rb +20 -0
- data/lib/jeweler/gemspec_helper.rb +79 -0
- data/lib/jeweler/generator.rb +306 -0
- data/lib/jeweler/generator/application.rb +54 -0
- data/lib/jeweler/generator/bacon_mixin.rb +43 -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 +102 -0
- data/lib/jeweler/generator/rdoc_mixin.rb +9 -0
- data/lib/jeweler/generator/rspec_mixin.rb +42 -0
- data/lib/jeweler/generator/shoulda_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/rubyforge_tasks.rb +98 -0
- data/lib/jeweler/specification.rb +66 -0
- data/lib/jeweler/tasks.rb +135 -0
- data/lib/jeweler/templates/.document +5 -0
- data/lib/jeweler/templates/.gitignore +5 -0
- data/lib/jeweler/templates/LICENSE +20 -0
- data/lib/jeweler/templates/README.rdoc +18 -0
- data/lib/jeweler/templates/Rakefile +153 -0
- data/lib/jeweler/templates/bacon/flunking.rb +7 -0
- data/lib/jeweler/templates/bacon/helper.rb +8 -0
- data/lib/jeweler/templates/features/default.feature +9 -0
- data/lib/jeweler/templates/features/support/env.rb +8 -0
- data/lib/jeweler/templates/micronaut/flunking.rb +7 -0
- data/lib/jeweler/templates/micronaut/helper.rb +17 -0
- data/lib/jeweler/templates/minitest/flunking.rb +7 -0
- data/lib/jeweler/templates/minitest/helper.rb +11 -0
- data/lib/jeweler/templates/rspec/flunking.rb +7 -0
- data/lib/jeweler/templates/rspec/helper.rb +10 -0
- data/lib/jeweler/templates/shoulda/flunking.rb +7 -0
- data/lib/jeweler/templates/shoulda/helper.rb +10 -0
- data/lib/jeweler/templates/testunit/flunking.rb +7 -0
- data/lib/jeweler/templates/testunit/helper.rb +9 -0
- data/lib/jeweler/version_helper.rb +128 -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-plaintext/.document +5 -0
- data/test/fixtures/existing-project-with-version-plaintext/.gitignore +5 -0
- data/test/fixtures/existing-project-with-version-plaintext/LICENSE +20 -0
- data/test/fixtures/existing-project-with-version-plaintext/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version-plaintext/Rakefile +82 -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 +20 -0
- data/test/fixtures/existing-project-with-version-yaml/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version-yaml/Rakefile +82 -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 +72 -0
- data/test/jeweler/commands/test_install_gem.rb +74 -0
- data/test/jeweler/commands/test_release.rb +362 -0
- data/test/jeweler/commands/test_release_to_rubyforge.rb +157 -0
- data/test/jeweler/commands/test_setup_rubyforge.rb +182 -0
- data/test/jeweler/commands/test_validate_gemspec.rb +27 -0
- data/test/jeweler/commands/test_write_gemspec.rb +92 -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 +23 -0
- data/test/shoulda_macros/jeweler_macros.rb +35 -0
- data/test/test_application.rb +139 -0
- data/test/test_gemspec_helper.rb +40 -0
- data/test/test_generator.rb +166 -0
- data/test/test_generator_initialization.rb +156 -0
- data/test/test_generator_mixins.rb +18 -0
- data/test/test_helper.rb +159 -0
- data/test/test_jeweler.rb +174 -0
- data/test/test_options.rb +149 -0
- data/test/test_specification.rb +61 -0
- data/test/test_tasks.rb +35 -0
- data/test/test_version_helper.rb +153 -0
- metadata +283 -0
@@ -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,182 @@
|
|
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 "package_exists?" do
|
11
|
+
setup do
|
12
|
+
stub(@gemspec).name { 'zomg' }
|
13
|
+
end
|
14
|
+
|
15
|
+
should "be true if rubyforge.lookup doesn't cause an Error" do
|
16
|
+
mock(@rubyforge).lookup('package', 'zomg')
|
17
|
+
|
18
|
+
assert @command.package_exists?
|
19
|
+
end
|
20
|
+
|
21
|
+
should "be false if rubyforge.lookup raises an error like: no <package_id> configured for <zomg>" do
|
22
|
+
mock(@rubyforge).lookup('package', 'zomg') do
|
23
|
+
raise RuntimeError, "no <package_id> configured for <zomg>"
|
24
|
+
end
|
25
|
+
|
26
|
+
assert ! @command.package_exists?
|
27
|
+
end
|
28
|
+
|
29
|
+
should "reraise any other Errors" do
|
30
|
+
mock(@rubyforge).lookup('package', 'zomg') do
|
31
|
+
raise RuntimeError, 'burnination!'
|
32
|
+
end
|
33
|
+
|
34
|
+
assert_raises RuntimeError, 'burnination!' do
|
35
|
+
@command.package_exists?
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
rubyforge_command_context "create_package" do
|
41
|
+
setup do
|
42
|
+
stub(@gemspec).name { 'zomg' }
|
43
|
+
end
|
44
|
+
|
45
|
+
context "when everything is happy" do
|
46
|
+
setup do
|
47
|
+
stub(@gemspec).rubyforge_project { 'myproject' }
|
48
|
+
stub(@rubyforge).create_package('myproject', 'zomg')
|
49
|
+
|
50
|
+
@command.create_package
|
51
|
+
end
|
52
|
+
|
53
|
+
should "create zomg package to myproject on rubyforge" do
|
54
|
+
assert_received(@rubyforge) {|rubyforge| rubyforge.create_package('myproject', 'zomg') }
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
context "when rubyforge project not existing or being setup in ~/.rubyforge/autoconfig.yml" do
|
60
|
+
setup do
|
61
|
+
stub(@gemspec).rubyforge_project { 'myproject' }
|
62
|
+
stub(@rubyforge).create_package('myproject', 'zomg')do
|
63
|
+
raise RuntimeError, "no <group_id> configured for <myproject>"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
should "raise RubyForgeProjectNotConfiguredError" do
|
68
|
+
assert_raises RubyForgeProjectNotConfiguredError do
|
69
|
+
@command.create_package
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
rubyforge_command_context "rubyforge_project defined in gemspec and project existing on rubyforge" do
|
77
|
+
setup do
|
78
|
+
stub(@rubyforge).configure
|
79
|
+
stub(@rubyforge).login
|
80
|
+
|
81
|
+
stub(@gemspec).name { 'zomg' }
|
82
|
+
stub(@gemspec).rubyforge_project { 'myproject' }
|
83
|
+
|
84
|
+
stub(@command).package_exists? { false }
|
85
|
+
stub(@command).create_package
|
86
|
+
@command.run
|
87
|
+
end
|
88
|
+
|
89
|
+
should "configure rubyforge" do
|
90
|
+
assert_received(@rubyforge) {|rubyforge| rubyforge.configure}
|
91
|
+
end
|
92
|
+
|
93
|
+
should "login to rubyforge" do
|
94
|
+
assert_received(@rubyforge) {|rubyforge| rubyforge.login}
|
95
|
+
end
|
96
|
+
|
97
|
+
should "create zomg package to myproject on rubyforge" do
|
98
|
+
assert_received(@command) {|command| command.create_package }
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
rubyforge_command_context "rubyforge_project defined in gemspec, project and project already existing on rubyforge" do
|
103
|
+
setup do
|
104
|
+
stub(@rubyforge).configure
|
105
|
+
stub(@rubyforge).login
|
106
|
+
|
107
|
+
|
108
|
+
stub(@gemspec).name { 'zomg' }
|
109
|
+
stub(@gemspec).rubyforge_project { 'myproject' }
|
110
|
+
|
111
|
+
stub(@command).package_exists? { true }
|
112
|
+
dont_allow(@command).create_package
|
113
|
+
@command.run
|
114
|
+
end
|
115
|
+
|
116
|
+
should "configure rubyforge" do
|
117
|
+
assert_received(@rubyforge) {|rubyforge| rubyforge.configure}
|
118
|
+
end
|
119
|
+
|
120
|
+
should "login to rubyforge" do
|
121
|
+
assert_received(@rubyforge) {|rubyforge| rubyforge.login}
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
rubyforge_command_context "rubyforge_project is not defined" do
|
128
|
+
setup do
|
129
|
+
stub(@gemspec).name { 'zomg' }
|
130
|
+
stub(@gemspec).rubyforge_project { nil }
|
131
|
+
end
|
132
|
+
|
133
|
+
should "raise NoRubyForgeProjectConfigured" do
|
134
|
+
assert_raises Jeweler::NoRubyForgeProjectInGemspecError do
|
135
|
+
@command.run
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
rubyforge_command_context "rubyforge project not existing or being setup in ~/.rubyforge/autoconfig.yml" do
|
141
|
+
setup do
|
142
|
+
stub(@rubyforge).configure
|
143
|
+
stub(@rubyforge).login
|
144
|
+
|
145
|
+
stub(@gemspec).name { 'zomg' }
|
146
|
+
stub(@gemspec).rubyforge_project { 'some_project_that_doesnt_exist' }
|
147
|
+
|
148
|
+
stub(@command).package_exists? { false }
|
149
|
+
stub(@command).create_package do
|
150
|
+
raise RubyForgeProjectNotConfiguredError, 'some_project_that_doesnt_exist'
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
should "raise RubyForgeProjectNotConfiguredError" do
|
155
|
+
assert_raises RubyForgeProjectNotConfiguredError do
|
156
|
+
@command.run
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
build_command_context "build for jeweler" do
|
163
|
+
setup do
|
164
|
+
@command = Jeweler::Commands::SetupRubyforge.build_for(@jeweler)
|
165
|
+
end
|
166
|
+
|
167
|
+
should "assign gemspec" do
|
168
|
+
assert_equal @gemspec, @command.gemspec
|
169
|
+
end
|
170
|
+
|
171
|
+
should "assign output" do
|
172
|
+
assert_equal @output, @command.output
|
173
|
+
end
|
174
|
+
|
175
|
+
should "assign rubyforge" do
|
176
|
+
assert_equal @rubyforge, @command.rubyforge
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Jeweler
|
4
|
+
module Commands
|
5
|
+
class TestValidateGemspec < Test::Unit::TestCase
|
6
|
+
|
7
|
+
build_command_context "build context" do
|
8
|
+
setup do
|
9
|
+
@command = Jeweler::Commands::ValidateGemspec.build_for(@jeweler)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "assign gemspec_helper" do
|
13
|
+
assert_same @gemspec_helper, @command.gemspec_helper
|
14
|
+
end
|
15
|
+
|
16
|
+
should "assign output" do
|
17
|
+
assert_same @output, @command.output
|
18
|
+
end
|
19
|
+
|
20
|
+
should "return Jeweler::Commands::ValidateGemspec" do
|
21
|
+
assert_kind_of Jeweler::Commands::ValidateGemspec, @command
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Jeweler
|
4
|
+
module Commands
|
5
|
+
class TestWriteGemspec < Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "after run" do
|
8
|
+
setup do
|
9
|
+
@gemspec = Gem::Specification.new {|s| s.name = 'zomg' }
|
10
|
+
@gemspec_helper = Object.new
|
11
|
+
stub(@gemspec_helper).spec { @gemspec }
|
12
|
+
stub(@gemspec_helper).path { 'zomg.gemspec' }
|
13
|
+
stub(@gemspec_helper).write
|
14
|
+
|
15
|
+
@output = StringIO.new
|
16
|
+
|
17
|
+
@version_helper = Object.new
|
18
|
+
stub(@version_helper).to_s { '1.2.3' }
|
19
|
+
stub(@version_helper).refresh
|
20
|
+
|
21
|
+
@command = Jeweler::Commands::WriteGemspec.new
|
22
|
+
@command.base_dir = 'tmp'
|
23
|
+
@command.version_helper = @version_helper
|
24
|
+
@command.gemspec = @gemspec
|
25
|
+
@command.output = @output
|
26
|
+
@command.gemspec_helper = @gemspec_helper
|
27
|
+
|
28
|
+
@now = Time.now
|
29
|
+
stub(Time.now).now { @now }
|
30
|
+
|
31
|
+
@command.run
|
32
|
+
end
|
33
|
+
|
34
|
+
should "refresh version" do
|
35
|
+
assert_received(@version_helper) {|version_helper| version_helper.refresh }
|
36
|
+
end
|
37
|
+
|
38
|
+
should "update gemspec version" do
|
39
|
+
assert_equal '1.2.3', @gemspec.version.to_s
|
40
|
+
end
|
41
|
+
|
42
|
+
should "update gemspec date to the beginning of today" do
|
43
|
+
assert_equal Time.mktime(@now.year, @now.month, @now.day, 0, 0), @gemspec.date
|
44
|
+
end
|
45
|
+
|
46
|
+
should "write gemspec" do
|
47
|
+
assert_received(@gemspec_helper) {|gemspec_helper| gemspec_helper.write }
|
48
|
+
end
|
49
|
+
|
50
|
+
should_eventually "output that the gemspec was written" do
|
51
|
+
assert_equal @output.string, "Generated: tmp/zomg.gemspec"
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
build_command_context "building for jeweler" do
|
57
|
+
setup do
|
58
|
+
@command = Jeweler::Commands::WriteGemspec.build_for(@jeweler)
|
59
|
+
end
|
60
|
+
|
61
|
+
should "assign base_dir" do
|
62
|
+
assert_same @base_dir, @command.base_dir
|
63
|
+
end
|
64
|
+
|
65
|
+
should "assign gemspec" do
|
66
|
+
assert_same @gemspec, @command.gemspec
|
67
|
+
end
|
68
|
+
|
69
|
+
should "assign version" do
|
70
|
+
assert_same @version, @command.version
|
71
|
+
end
|
72
|
+
|
73
|
+
should "assign output" do
|
74
|
+
assert_same @output, @command.output
|
75
|
+
end
|
76
|
+
|
77
|
+
should "assign gemspec_helper" do
|
78
|
+
assert_same @gemspec_helper, @command.gemspec_helper
|
79
|
+
end
|
80
|
+
|
81
|
+
should "assign version_helper" do
|
82
|
+
assert_same @version_helper, @command.version_helper
|
83
|
+
end
|
84
|
+
|
85
|
+
should "return WriteGemspec" do
|
86
|
+
assert_kind_of Jeweler::Commands::WriteGemspec, @command
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|