jeweler2 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +8 -0
- data/ChangeLog.markdown +177 -0
- data/Gemfile +18 -0
- data/Gemfile.lock +47 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +217 -0
- data/Rakefile +80 -0
- data/bin/jeweler +5 -0
- data/features/generator/cucumber.feature +103 -0
- data/features/generator/directory_layout.feature +86 -0
- data/features/generator/dotdocument.feature +13 -0
- data/features/generator/env_options.feature +9 -0
- data/features/generator/gemfile.feature +71 -0
- data/features/generator/git.feature +102 -0
- data/features/generator/license.feature +20 -0
- data/features/generator/rakefile.feature +158 -0
- data/features/generator/readme.feature +12 -0
- data/features/generator/test.feature +54 -0
- data/features/generator/test_helper.feature +149 -0
- data/features/placeholder.feature +5 -0
- data/features/step_definitions/debug_steps.rb +6 -0
- data/features/step_definitions/filesystem_steps.rb +70 -0
- data/features/step_definitions/generator_steps.rb +380 -0
- data/features/step_definitions/task_steps.rb +6 -0
- data/features/support/env.rb +42 -0
- data/features/tasks/build_gem.feature +9 -0
- data/features/tasks/version.feature +31 -0
- data/features/tasks/version_bumping.feature +49 -0
- data/jeweler.gemspec +245 -0
- data/jeweler2.gemspec +233 -0
- data/lib/jeweler/commands/build_gem.rb +36 -0
- data/lib/jeweler/commands/check_dependencies.rb +66 -0
- data/lib/jeweler/commands/install_gem.rb +31 -0
- data/lib/jeweler/commands/release_gemspec.rb +82 -0
- data/lib/jeweler/commands/release_to_git.rb +59 -0
- data/lib/jeweler/commands/release_to_rubygems.rb +28 -0
- data/lib/jeweler/commands/validate_gemspec.rb +30 -0
- data/lib/jeweler/commands/version/base.rb +55 -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/commands.rb +20 -0
- data/lib/jeweler/errors.rb +8 -0
- data/lib/jeweler/gemcutter_tasks.rb +8 -0
- data/lib/jeweler/gemspec_helper.rb +87 -0
- data/lib/jeweler/generator/application.rb +61 -0
- data/lib/jeweler/generator/bacon_mixin.rb +43 -0
- data/lib/jeweler/generator/github_mixin.rb +29 -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 +163 -0
- data/lib/jeweler/generator/rdoc_mixin.rb +9 -0
- data/lib/jeweler/generator/riot_mixin.rb +42 -0
- data/lib/jeweler/generator/rspec_mixin.rb +42 -0
- data/lib/jeweler/generator/shindo_mixin.rb +44 -0
- data/lib/jeweler/generator/shoulda_mixin.rb +42 -0
- data/lib/jeweler/generator/testspec_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/generator.rb +295 -0
- data/lib/jeweler/rubyforge_tasks.rb +95 -0
- data/lib/jeweler/rubygems_dot_org_tasks.rb +38 -0
- data/lib/jeweler/rubygems_tasks.rb +38 -0
- data/lib/jeweler/specification.rb +110 -0
- data/lib/jeweler/tasks.rb +224 -0
- data/lib/jeweler/templates/.document +5 -0
- data/lib/jeweler/templates/.gitignore +48 -0
- data/lib/jeweler/templates/Gemfile +12 -0
- data/lib/jeweler/templates/LICENSE.txt +20 -0
- data/lib/jeweler/templates/README.rdoc +19 -0
- data/lib/jeweler/templates/Rakefile +9 -0
- data/lib/jeweler/templates/bacon/flunking.rb +7 -0
- data/lib/jeweler/templates/bacon/helper.rb +9 -0
- data/lib/jeweler/templates/bundler_setup.erb +10 -0
- data/lib/jeweler/templates/features/default.feature +9 -0
- data/lib/jeweler/templates/features/support/env.rb +10 -0
- data/lib/jeweler/templates/jeweler_tasks.erb +31 -0
- data/lib/jeweler/templates/micronaut/flunking.rb +7 -0
- data/lib/jeweler/templates/micronaut/helper.rb +18 -0
- data/lib/jeweler/templates/minitest/flunking.rb +7 -0
- data/lib/jeweler/templates/minitest/helper.rb +12 -0
- data/lib/jeweler/templates/other_tasks.erb +86 -0
- data/lib/jeweler/templates/riot/flunking.rb +11 -0
- data/lib/jeweler/templates/riot/helper.rb +4 -0
- data/lib/jeweler/templates/rspec/.rspec +1 -0
- data/lib/jeweler/templates/rspec/flunking.rb +7 -0
- data/lib/jeweler/templates/rspec/helper.rb +12 -0
- data/lib/jeweler/templates/shindo/flunking.rb +8 -0
- data/lib/jeweler/templates/shindo/helper.rb +6 -0
- data/lib/jeweler/templates/shoulda/flunking.rb +7 -0
- data/lib/jeweler/templates/shoulda/helper.rb +11 -0
- data/lib/jeweler/templates/testspec/flunking.rb +7 -0
- data/lib/jeweler/templates/testspec/helper.rb +7 -0
- data/lib/jeweler/templates/testunit/flunking.rb +7 -0
- data/lib/jeweler/templates/testunit/helper.rb +10 -0
- data/lib/jeweler/version.rb +10 -0
- data/lib/jeweler/version_helper.rb +141 -0
- data/lib/jeweler.rb +177 -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-constant/.document +5 -0
- data/test/fixtures/existing-project-with-version-constant/.gitignore +5 -0
- data/test/fixtures/existing-project-with-version-constant/LICENSE.txt +20 -0
- data/test/fixtures/existing-project-with-version-constant/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version-constant/Rakefile +85 -0
- data/test/fixtures/existing-project-with-version-constant/existing-project-with-version.gemspec +29 -0
- data/test/fixtures/existing-project-with-version-constant/lib/existing_project_with_version.rb +0 -0
- data/test/fixtures/existing-project-with-version-constant/test/existing_project_with_version_test.rb +7 -0
- data/test/fixtures/existing-project-with-version-constant/test/test_helper.rb +10 -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.txt +20 -0
- data/test/fixtures/existing-project-with-version-plaintext/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version-plaintext/Rakefile +84 -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.txt +20 -0
- data/test/fixtures/existing-project-with-version-yaml/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version-yaml/Rakefile +84 -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 +103 -0
- data/test/jeweler/commands/test_install_gem.rb +35 -0
- data/test/jeweler/commands/test_release_to_gemcutter.rb +39 -0
- data/test/jeweler/commands/test_release_to_git.rb +198 -0
- data/test/jeweler/commands/test_release_to_github.rb +390 -0
- data/test/jeweler/commands/test_validate_gemspec.rb +27 -0
- data/test/jeweler/commands/test_write_gemspec.rb +101 -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 +22 -0
- data/test/jeweler/generator/test_application.rb +120 -0
- data/test/jeweler/generator/test_options.rb +225 -0
- data/test/jeweler/test_gemspec_helper.rb +44 -0
- data/test/jeweler/test_generator.rb +141 -0
- data/test/jeweler/test_generator_initialization.rb +164 -0
- data/test/jeweler/test_generator_mixins.rb +23 -0
- data/test/jeweler/test_specification.rb +237 -0
- data/test/jeweler/test_tasks.rb +50 -0
- data/test/jeweler/test_version_helper.rb +214 -0
- data/test/shoulda_macros/jeweler_macros.rb +35 -0
- data/test/test_helper.rb +178 -0
- data/test/test_jeweler.rb +175 -0
- metadata +343 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestGeneratorMixins < Test::Unit::TestCase
|
4
|
+
|
5
|
+
[Jeweler::Generator::BaconMixin,
|
6
|
+
Jeweler::Generator::MicronautMixin,
|
7
|
+
Jeweler::Generator::MinitestMixin,
|
8
|
+
Jeweler::Generator::RspecMixin,
|
9
|
+
Jeweler::Generator::ShouldaMixin,
|
10
|
+
Jeweler::Generator::TestspecMixin,
|
11
|
+
Jeweler::Generator::TestunitMixin,
|
12
|
+
].each do |mixin|
|
13
|
+
context "#{mixin}" do
|
14
|
+
%w(default_task feature_support_require feature_support_extend
|
15
|
+
test_dir test_task test_pattern test_filename
|
16
|
+
test_helper_filename).each do |method|
|
17
|
+
should "define #{method}" do
|
18
|
+
assert mixin.method_defined?(method)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,237 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestSpecification < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@project = create_construct
|
6
|
+
end
|
7
|
+
|
8
|
+
def teardown
|
9
|
+
@project.destroy!
|
10
|
+
end
|
11
|
+
|
12
|
+
def build_jeweler_gemspec(&block)
|
13
|
+
gemspec = if block
|
14
|
+
Gem::Specification.new(&block)
|
15
|
+
else
|
16
|
+
Gem::Specification.new()
|
17
|
+
end
|
18
|
+
gemspec.extend(Jeweler::Specification)
|
19
|
+
gemspec
|
20
|
+
end
|
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
|
+
|
29
|
+
context "basic defaults" do
|
30
|
+
setup do
|
31
|
+
@gemspec = build_jeweler_gemspec
|
32
|
+
end
|
33
|
+
|
34
|
+
should "make files a FileList" do
|
35
|
+
assert_equal FileList, @gemspec.files.class
|
36
|
+
end
|
37
|
+
|
38
|
+
should "make extra_rdoc_files a FileList" do
|
39
|
+
assert_equal FileList, @gemspec.extra_rdoc_files.class
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
context "there aren't any executables in the project directory" do
|
45
|
+
setup do
|
46
|
+
@project.directory 'bin'
|
47
|
+
end
|
48
|
+
|
49
|
+
context "and there hasn't been any set on the gemspec" do
|
50
|
+
setup do
|
51
|
+
@gemspec = build_jeweler_gemspec
|
52
|
+
@gemspec.set_jeweler_defaults(@project)
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
should "have empty gemspec executables" do
|
57
|
+
assert_equal [], @gemspec.executables
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context "and has been previously set executables" do
|
62
|
+
setup do
|
63
|
+
@gemspec = build_jeweler_gemspec do |gemspec|
|
64
|
+
gemspec.executables = %w(non-existant)
|
65
|
+
end
|
66
|
+
@gemspec.set_jeweler_defaults(@project)
|
67
|
+
end
|
68
|
+
|
69
|
+
should "have only the original executables in the gemspec" do
|
70
|
+
assert_equal %w(non-existant), @gemspec.executables
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context "there are multiple executables in the project directory" do
|
76
|
+
setup do
|
77
|
+
@project.directory('bin') do |bin|
|
78
|
+
bin.file 'burnination'
|
79
|
+
bin.file 'trogdor'
|
80
|
+
end
|
81
|
+
repo = Git.init(@project.to_s)
|
82
|
+
repo.add('bin/burnination')
|
83
|
+
repo.commit('Initial commit')
|
84
|
+
end
|
85
|
+
|
86
|
+
context "and there hasn't been any set on the gemspec" do
|
87
|
+
setup do
|
88
|
+
@gemspec = build_jeweler_gemspec
|
89
|
+
@gemspec.set_jeweler_defaults(@project)
|
90
|
+
end
|
91
|
+
|
92
|
+
should "have the executables under version control in the gemspec" do
|
93
|
+
assert_equal %w(burnination), @gemspec.executables
|
94
|
+
end
|
95
|
+
end
|
96
|
+
context "and has been previously set executables" do
|
97
|
+
setup do
|
98
|
+
@gemspec = build_jeweler_gemspec do |gemspec|
|
99
|
+
gemspec.executables = %w(burnination)
|
100
|
+
end
|
101
|
+
@gemspec.set_jeweler_defaults(@project)
|
102
|
+
end
|
103
|
+
should "have only the original executables in the gemspec" do
|
104
|
+
assert_equal %w(burnination), @gemspec.executables
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context "there are mutiple extconf.rb and mkrf_conf.rb in the project directory" do
|
110
|
+
setup do
|
111
|
+
@project.directory('ext') do |ext|
|
112
|
+
ext.file 'extconf.rb'
|
113
|
+
ext.file 'mkrf_conf.rb'
|
114
|
+
ext.directory('trogdor_native') do |trogdor_native|
|
115
|
+
trogdor_native.file 'extconf.rb'
|
116
|
+
trogdor_native.file 'mkrf_conf.rb'
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
context "and there hasn't been any extensions set on the gemspec" do
|
122
|
+
setup do
|
123
|
+
@gemspec = build_jeweler_gemspec
|
124
|
+
@gemspec.set_jeweler_defaults(@project)
|
125
|
+
end
|
126
|
+
|
127
|
+
should "have all the extconf.rb and mkrf_config.rb files in extensions" do
|
128
|
+
assert_equal %w(ext/mkrf_conf.rb ext/trogdor_native/mkrf_conf.rb ext/extconf.rb ext/trogdor_native/extconf.rb).sort, @gemspec.extensions.sort
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
|
135
|
+
context "there are some files and is setup for git" do
|
136
|
+
setup do
|
137
|
+
@project.file 'Rakefile'
|
138
|
+
@project.directory('lib') do |lib|
|
139
|
+
lib.file 'example.rb'
|
140
|
+
end
|
141
|
+
|
142
|
+
repo = Git.init(@project.to_s)
|
143
|
+
repo.add('.')
|
144
|
+
repo.commit('Initial commit')
|
145
|
+
end
|
146
|
+
|
147
|
+
context "and the files defaults are used" do
|
148
|
+
setup do
|
149
|
+
@gemspec = build_jeweler_gemspec
|
150
|
+
@gemspec.set_jeweler_defaults(@project, @project)
|
151
|
+
end
|
152
|
+
|
153
|
+
should "populate files from git" do
|
154
|
+
assert_equal %w(Rakefile lib/example.rb), @gemspec.files.sort
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
context "and the files specified manually" do
|
159
|
+
setup do
|
160
|
+
@gemspec = build_jeweler_gemspec do |gemspec|
|
161
|
+
gemspec.files = %w(Rakefile)
|
162
|
+
end
|
163
|
+
@gemspec.set_jeweler_defaults(@project, @project)
|
164
|
+
end
|
165
|
+
|
166
|
+
should "not be overridden by files from git" do
|
167
|
+
assert_equal %w(Rakefile), @gemspec.files
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
172
|
+
|
173
|
+
context "there are some files and is setup for git with ignored files" do
|
174
|
+
setup do
|
175
|
+
@project.file '.gitignore', 'ignored'
|
176
|
+
@project.file 'ignored'
|
177
|
+
@project.file 'Rakefile'
|
178
|
+
@project.directory('lib') do |lib|
|
179
|
+
lib.file 'example.rb'
|
180
|
+
end
|
181
|
+
|
182
|
+
repo = Git.init(@project.to_s)
|
183
|
+
repo.add('.')
|
184
|
+
repo.commit('Initial commit')
|
185
|
+
|
186
|
+
|
187
|
+
@gemspec = build_jeweler_gemspec
|
188
|
+
@gemspec.set_jeweler_defaults(@project, @project)
|
189
|
+
end
|
190
|
+
|
191
|
+
should "populate files from git excluding ignored and .gitignore" do
|
192
|
+
assert_equal %w(Rakefile lib/example.rb), @gemspec.files.sort
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
context "there are some files and is setup for git and working in a sub directory" do
|
197
|
+
setup do
|
198
|
+
@subproject = File.join(@project, 'subproject')
|
199
|
+
@project.file 'Rakefile'
|
200
|
+
@project.file 'README'
|
201
|
+
@project.directory 'subproject' do |subproject|
|
202
|
+
subproject.file 'README'
|
203
|
+
subproject.directory('lib') do |lib|
|
204
|
+
lib.file 'subproject_example.rb'
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
repo = Git.init(@project.to_s)
|
209
|
+
repo.add('.')
|
210
|
+
repo.commit('Initial commit')
|
211
|
+
|
212
|
+
@gemspec = build_jeweler_gemspec
|
213
|
+
@gemspec.set_jeweler_defaults(@subproject, @project)
|
214
|
+
end
|
215
|
+
|
216
|
+
should "populate files from git relative to sub directory" do
|
217
|
+
assert_equal %w(lib/subproject_example.rb README).sort, @gemspec.files.sort
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
context "there are some files and is not setup for git" do
|
222
|
+
setup do
|
223
|
+
@project.file 'Rakefile'
|
224
|
+
@project.directory('lib') do |lib|
|
225
|
+
lib.file 'example.rb'
|
226
|
+
end
|
227
|
+
|
228
|
+
@gemspec = build_jeweler_gemspec
|
229
|
+
@gemspec.set_jeweler_defaults(@project, @project)
|
230
|
+
end
|
231
|
+
|
232
|
+
should "not populate files" do
|
233
|
+
assert_equal [], @gemspec.files.sort
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
require 'rake'
|
4
|
+
class TestTasks < Test::Unit::TestCase
|
5
|
+
include Rake
|
6
|
+
|
7
|
+
context 'instantiating Jeweler::Tasks' do
|
8
|
+
setup do
|
9
|
+
@gemspec_building_block = lambda {|gemspec|}
|
10
|
+
@tasks = Jeweler::Tasks.new &@gemspec_building_block
|
11
|
+
end
|
12
|
+
|
13
|
+
teardown do
|
14
|
+
Task.clear
|
15
|
+
end
|
16
|
+
|
17
|
+
should 'assign @gemspec' do
|
18
|
+
assert_not_nil @tasks.gemspec
|
19
|
+
end
|
20
|
+
|
21
|
+
should 'not eagerly initialize Jeweler' do
|
22
|
+
assert ! @tasks.instance_variable_defined?(:@jeweler)
|
23
|
+
end
|
24
|
+
|
25
|
+
should 'set self as the application-wide jeweler tasks' do
|
26
|
+
assert_same @tasks, Rake.application.jeweler_tasks
|
27
|
+
end
|
28
|
+
|
29
|
+
should 'save gemspec building block for later' do
|
30
|
+
assert_same @gemspec_building_block, @tasks.gemspec_building_block
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'Jeweler instance' do
|
34
|
+
setup do
|
35
|
+
@tasks.jeweler
|
36
|
+
end
|
37
|
+
|
38
|
+
should 'initailize Jeweler' do
|
39
|
+
assert @tasks.instance_variable_defined?(:@jeweler)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
should 'yield the gemspec instance' do
|
44
|
+
spec = nil
|
45
|
+
@tasks = Jeweler::Tasks.new { |s| spec = s }
|
46
|
+
assert_not_nil @tasks.jeweler.gemspec
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,214 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestVersionHelper < Test::Unit::TestCase
|
4
|
+
|
5
|
+
VERSION_TMP_DIR = File.dirname(__FILE__) + '/version_tmp'
|
6
|
+
|
7
|
+
def self.should_have_version(major, minor, patch, build=nil)
|
8
|
+
should "have major version #{major}" do
|
9
|
+
assert_equal major, @version_helper.major
|
10
|
+
end
|
11
|
+
|
12
|
+
should "have minor version #{minor}" do
|
13
|
+
assert_equal minor, @version_helper.minor
|
14
|
+
end
|
15
|
+
|
16
|
+
should "have patch version #{patch}" do
|
17
|
+
assert_equal patch, @version_helper.patch
|
18
|
+
end
|
19
|
+
|
20
|
+
should "have build version #{build}" do
|
21
|
+
assert_equal build, @version_helper.build
|
22
|
+
end
|
23
|
+
|
24
|
+
version_s = [major, minor, patch, build].compact.join('.')
|
25
|
+
should "render string as #{version_s.inspect}" do
|
26
|
+
assert_equal version_s, @version_helper.to_s
|
27
|
+
end
|
28
|
+
|
29
|
+
#version_hash = {:major => major, :minor => minor, :patch => patch}
|
30
|
+
#should "render hash as #{version_hash.inspect}" do
|
31
|
+
#assert_equal version_hash, @version_helper.to_hash
|
32
|
+
#end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
context "VERSION.yml with 3.5.4" do
|
37
|
+
setup do
|
38
|
+
FileUtils.rm_rf VERSION_TMP_DIR
|
39
|
+
FileUtils.mkdir_p VERSION_TMP_DIR
|
40
|
+
|
41
|
+
build_version_yml VERSION_TMP_DIR, 3, 5, 4
|
42
|
+
|
43
|
+
@version_helper = Jeweler::VersionHelper.new VERSION_TMP_DIR
|
44
|
+
end
|
45
|
+
|
46
|
+
should_have_version 3, 5, 4
|
47
|
+
|
48
|
+
context "bumping major version" do
|
49
|
+
setup { @version_helper.bump_major }
|
50
|
+
should_have_version 4, 0, 0
|
51
|
+
end
|
52
|
+
|
53
|
+
context "bumping the minor version" do
|
54
|
+
setup { @version_helper.bump_minor }
|
55
|
+
should_have_version 3, 6, 0
|
56
|
+
end
|
57
|
+
|
58
|
+
context "bumping the patch version" do
|
59
|
+
setup { @version_helper.bump_patch }
|
60
|
+
should_have_version 3, 5, 5
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "VERSION.yml with 3.5.4.a1" do
|
65
|
+
setup do
|
66
|
+
FileUtils.rm_rf VERSION_TMP_DIR
|
67
|
+
FileUtils.mkdir_p VERSION_TMP_DIR
|
68
|
+
|
69
|
+
build_version_yml VERSION_TMP_DIR, 3, 5, 4, 'a1'
|
70
|
+
|
71
|
+
@version_helper = Jeweler::VersionHelper.new VERSION_TMP_DIR
|
72
|
+
end
|
73
|
+
|
74
|
+
should_have_version 3, 5, 4, 'a1'
|
75
|
+
|
76
|
+
context "bumping major version" do
|
77
|
+
setup { @version_helper.bump_major }
|
78
|
+
should_have_version 4, 0, 0, nil
|
79
|
+
end
|
80
|
+
|
81
|
+
context "bumping the minor version" do
|
82
|
+
setup { @version_helper.bump_minor }
|
83
|
+
should_have_version 3, 6, 0, nil
|
84
|
+
end
|
85
|
+
|
86
|
+
context "bumping the patch version" do
|
87
|
+
setup { @version_helper.bump_patch }
|
88
|
+
should_have_version 3, 5, 5, nil
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context "VERSION with 3.5.4" do
|
93
|
+
setup do
|
94
|
+
FileUtils.rm_rf VERSION_TMP_DIR
|
95
|
+
FileUtils.mkdir_p VERSION_TMP_DIR
|
96
|
+
|
97
|
+
build_version_plaintext VERSION_TMP_DIR, 3, 5, 4
|
98
|
+
|
99
|
+
@version_helper = Jeweler::VersionHelper.new VERSION_TMP_DIR
|
100
|
+
end
|
101
|
+
|
102
|
+
should_have_version 3, 5, 4
|
103
|
+
|
104
|
+
context "bumping major version" do
|
105
|
+
setup { @version_helper.bump_major }
|
106
|
+
should_have_version 4, 0, 0
|
107
|
+
end
|
108
|
+
|
109
|
+
context "bumping the minor version" do
|
110
|
+
setup { @version_helper.bump_minor }
|
111
|
+
should_have_version 3, 6, 0
|
112
|
+
end
|
113
|
+
|
114
|
+
context "bumping the patch version" do
|
115
|
+
setup { @version_helper.bump_patch }
|
116
|
+
should_have_version 3, 5, 5
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
context "VERSION with 3.5.4.a1" do
|
121
|
+
setup do
|
122
|
+
FileUtils.rm_rf VERSION_TMP_DIR
|
123
|
+
FileUtils.mkdir_p VERSION_TMP_DIR
|
124
|
+
|
125
|
+
build_version_plaintext VERSION_TMP_DIR, 3, 5, 4, 'a1'
|
126
|
+
|
127
|
+
@version_helper = Jeweler::VersionHelper.new VERSION_TMP_DIR
|
128
|
+
end
|
129
|
+
|
130
|
+
should_have_version 3, 5, 4, 'a1'
|
131
|
+
|
132
|
+
context "bumping major version" do
|
133
|
+
setup { @version_helper.bump_major }
|
134
|
+
should_have_version 4, 0, 0, nil
|
135
|
+
end
|
136
|
+
|
137
|
+
context "bumping the minor version" do
|
138
|
+
setup { @version_helper.bump_minor }
|
139
|
+
should_have_version 3, 6, 0, nil
|
140
|
+
end
|
141
|
+
|
142
|
+
context "bumping the patch version" do
|
143
|
+
setup { @version_helper.bump_patch }
|
144
|
+
should_have_version 3, 5, 5, nil
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
context "Non-existant VERSION.yml" do
|
149
|
+
setup do
|
150
|
+
FileUtils.rm_rf VERSION_TMP_DIR
|
151
|
+
FileUtils.mkdir_p VERSION_TMP_DIR
|
152
|
+
end
|
153
|
+
|
154
|
+
should "not raise error if the VERSION.yml doesn't exist" do
|
155
|
+
assert_nothing_raised Jeweler::VersionYmlError do
|
156
|
+
Jeweler::VersionHelper.new(VERSION_TMP_DIR)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
context "setting an initial version" do
|
161
|
+
setup do
|
162
|
+
@version_helper = Jeweler::VersionHelper.new(VERSION_TMP_DIR)
|
163
|
+
@version_helper.update_to 0, 0, 1
|
164
|
+
end
|
165
|
+
|
166
|
+
should_have_version 0, 0, 1
|
167
|
+
should "not create VERSION.yml" do
|
168
|
+
assert ! File.exists?(File.join(VERSION_TMP_DIR, 'VERSION.yml'))
|
169
|
+
end
|
170
|
+
should "not create VERSION" do
|
171
|
+
assert ! File.exists?(File.join(VERSION_TMP_DIR, 'VERSION'))
|
172
|
+
end
|
173
|
+
|
174
|
+
context "outputting" do
|
175
|
+
setup do
|
176
|
+
@version_helper.write
|
177
|
+
end
|
178
|
+
|
179
|
+
should "create VERSION" do
|
180
|
+
assert File.exists?(File.join(VERSION_TMP_DIR, 'VERSION'))
|
181
|
+
end
|
182
|
+
|
183
|
+
context "re-reading VERSION" do
|
184
|
+
setup do
|
185
|
+
@version_helper = Jeweler::VersionHelper.new(VERSION_TMP_DIR)
|
186
|
+
end
|
187
|
+
|
188
|
+
should_have_version 0, 0, 1
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def build_version_yml(base_dir, major, minor, patch, build=nil)
|
195
|
+
version_path = File.join(base_dir, 'VERSION.yml')
|
196
|
+
|
197
|
+
File.open(version_path, 'w+') do |f|
|
198
|
+
version_hash = {
|
199
|
+
'major' => major.to_i,
|
200
|
+
'minor' => minor.to_i,
|
201
|
+
'patch' => patch.to_i
|
202
|
+
}
|
203
|
+
version_hash['build'] = build if build
|
204
|
+
YAML.dump(version_hash, f)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
def build_version_plaintext(base_dir, major, minor, patch, build=nil)
|
209
|
+
version_path = File.join(base_dir, 'VERSION')
|
210
|
+
File.open(version_path, 'w+') do |f|
|
211
|
+
f.puts [major, minor, patch, build].compact.join('.')
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class Test::Unit::TestCase
|
2
|
+
class << self
|
3
|
+
def should_have_major_version(version)
|
4
|
+
should "have major version of #{version}" do
|
5
|
+
assert_equal version, @jeweler.major_version
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def should_have_minor_version(version)
|
10
|
+
should "have minor version of #{version}" do
|
11
|
+
assert_equal version, @jeweler.minor_version
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def should_have_patch_version(version)
|
16
|
+
should "have patch version of #{version}" do
|
17
|
+
assert_equal version, @jeweler.patch_version
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def should_be_version(version)
|
22
|
+
should "be version #{version}" do
|
23
|
+
assert_equal version, @jeweler.version
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def should_bump_version(major, minor, patch)
|
28
|
+
version = "#{major}.#{minor}.#{patch}"
|
29
|
+
should_have_major_version major
|
30
|
+
should_have_minor_version minor
|
31
|
+
should_have_patch_version patch
|
32
|
+
should_be_version version
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|