technicalpickles-jeweler 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. data/ChangeLog.markdown +27 -7
  2. data/README.markdown +9 -3
  3. data/Rakefile +30 -24
  4. data/TODO +2 -2
  5. data/VERSION.yml +2 -2
  6. data/bin/jeweler +1 -77
  7. data/lib/jeweler/commands/build_gem.rb +22 -0
  8. data/lib/jeweler/commands/install_gem.rb +19 -0
  9. data/lib/jeweler/commands/release.rb +45 -0
  10. data/lib/jeweler/commands/validate_gemspec.rb +21 -0
  11. data/lib/jeweler/commands/version/base.rb +30 -0
  12. data/lib/jeweler/commands/version/bump_major.rb +13 -0
  13. data/lib/jeweler/commands/version/bump_minor.rb +12 -0
  14. data/lib/jeweler/commands/version/bump_patch.rb +14 -0
  15. data/lib/jeweler/commands/version/write.rb +12 -0
  16. data/lib/jeweler/commands/write_gemspec.rb +26 -0
  17. data/lib/jeweler/commands.rb +10 -0
  18. data/lib/jeweler/{gemspec.rb → gemspec_helper.rb} +7 -1
  19. data/lib/jeweler/generator/application.rb +45 -0
  20. data/lib/jeweler/generator/options.rb +64 -0
  21. data/lib/jeweler/generator.rb +66 -26
  22. data/lib/jeweler/tasks.rb +11 -29
  23. data/lib/jeweler/templates/.gitignore +3 -1
  24. data/lib/jeweler/templates/LICENSE +1 -1
  25. data/lib/jeweler/templates/README.rdoc +7 -0
  26. data/lib/jeweler/templates/Rakefile +48 -31
  27. data/lib/jeweler/templates/bacon/flunking.rb +1 -1
  28. data/lib/jeweler/templates/bacon/helper.rb +1 -1
  29. data/lib/jeweler/templates/features/support/env.rb +0 -2
  30. data/lib/jeweler/templates/micronaut/flunking.rb +7 -0
  31. data/lib/jeweler/templates/micronaut/helper.rb +17 -0
  32. data/lib/jeweler/templates/minitest/flunking.rb +1 -1
  33. data/lib/jeweler/templates/minitest/helper.rb +1 -0
  34. data/lib/jeweler/templates/rspec/flunking.rb +1 -1
  35. data/lib/jeweler/templates/rspec/helper.rb +1 -1
  36. data/lib/jeweler/templates/shoulda/flunking.rb +2 -2
  37. data/lib/jeweler/templates/shoulda/helper.rb +1 -1
  38. data/lib/jeweler/templates/testunit/flunking.rb +1 -1
  39. data/lib/jeweler/templates/testunit/helper.rb +1 -1
  40. data/lib/jeweler/{version.rb → version_helper.rb} +1 -1
  41. data/lib/jeweler.rb +59 -141
  42. data/test/jeweler/commands/test_build_gem.rb +53 -0
  43. data/{lib/jeweler/templates/features/steps/default_steps.rb → test/jeweler/commands/test_install_gem.rb} +0 -0
  44. data/test/jeweler/commands/test_release.rb +145 -0
  45. data/test/jeweler/commands/test_write_gemspec.rb +58 -0
  46. data/test/jeweler/commands/version/test_bump_major.rb +21 -0
  47. data/test/jeweler/commands/version/test_bump_minor.rb +19 -0
  48. data/test/jeweler/commands/version/test_bump_patch.rb +20 -0
  49. data/test/jeweler/commands/version/test_write.rb +23 -0
  50. data/test/test_application.rb +109 -0
  51. data/test/{test_gemspec.rb → test_gemspec_helper.rb} +9 -5
  52. data/test/test_generator.rb +179 -0
  53. data/test/test_helper.rb +11 -23
  54. data/test/test_jeweler.rb +12 -9
  55. data/test/test_options.rb +90 -0
  56. data/test/test_tasks.rb +3 -4
  57. data/test/{test_version.rb → test_version_helper.rb} +16 -16
  58. metadata +44 -11
  59. data/lib/jeweler/templates/README +0 -9
@@ -0,0 +1,109 @@
1
+ require 'test_helper'
2
+
3
+ class TestApplication < Test::Unit::TestCase
4
+ def run_application(*arguments)
5
+ original_stdout = $stdout
6
+ original_stderr = $stderr
7
+
8
+ fake_stdout = StringIO.new
9
+ fake_stderr = StringIO.new
10
+
11
+ $stdout = fake_stdout
12
+ $stderr = fake_stderr
13
+
14
+ result = nil
15
+ begin
16
+ result = Jeweler::Generator::Application.run!(*arguments)
17
+ ensure
18
+ $stdout = original_stdout
19
+ $stderr = original_stderr
20
+ end
21
+
22
+ @stdout = fake_stdout.string
23
+ @stderr = fake_stderr.string
24
+
25
+ result
26
+ end
27
+
28
+ def self.should_exit_with_code(code)
29
+ should "exit with code #{code}" do
30
+ assert_equal code, @result
31
+ end
32
+ end
33
+
34
+ context "called without any args" do
35
+ setup do
36
+ @result = run_application
37
+ end
38
+
39
+ should_exit_with_code 1
40
+
41
+ should 'display usage on stderr' do
42
+ assert_match 'Usage:', @stderr
43
+ end
44
+
45
+ should 'not display anything on stdout' do
46
+ assert_equal '', @stdout.squeeze.strip
47
+ end
48
+ end
49
+
50
+ def build_generator(name = 'zomg', options = {:testing_framework => :shoulda})
51
+ Jeweler::Generator.new(name, options)
52
+ end
53
+
54
+ context "called with -h" do
55
+ setup do
56
+ @generator = build_generator
57
+ stub(@generator).run
58
+ stub(Jeweler::Generator).new { raise "Shouldn't have made this far"}
59
+
60
+ assert_nothing_raised do
61
+ @result = run_application("-h")
62
+ end
63
+ end
64
+
65
+ should_exit_with_code 1
66
+
67
+ should 'display usage on stderr' do
68
+ assert_match 'Usage:', @stderr
69
+ end
70
+
71
+ should 'not display anything on stdout' do
72
+ assert_equal '', @stdout.squeeze.strip
73
+ end
74
+ end
75
+
76
+ context "when called with repo name" do
77
+ setup do
78
+ @options = {:testing_framework => :shoulda}
79
+ @generator = build_generator('zomg', @options)
80
+
81
+ stub(@generator).run
82
+ stub(Jeweler::Generator).new { @generator }
83
+ end
84
+
85
+ should 'return exit code 0' do
86
+ result = run_application("zomg")
87
+ assert_equal 0, result
88
+ end
89
+
90
+ should 'create generator with repo name and no options' do
91
+ run_application("zomg")
92
+
93
+ assert_received Jeweler::Generator do |subject|
94
+ subject.new('zomg', @options)
95
+ end
96
+ end
97
+
98
+ should 'run generator' do
99
+ run_application("zomg")
100
+
101
+ assert_received(@generator) {|subject| subject.run }
102
+ end
103
+
104
+ should 'not display usage on stderr' do
105
+ assert_no_match /Usage:/, @stderr
106
+ end
107
+ end
108
+
109
+ end
@@ -1,7 +1,7 @@
1
- require File.dirname(__FILE__) + '/test_helper'
1
+ require 'test_helper'
2
2
 
3
- class TestGemspec < Test::Unit::TestCase
4
- context "A Jeweler::GemSpec, given a gemspec" do
3
+ class TestGemspecHelper < Test::Unit::TestCase
4
+ context "given a gemspec" do
5
5
  setup do
6
6
  @spec = build_spec
7
7
  @helper = Jeweler::GemSpecHelper.new(@spec, File.dirname(__FILE__))
@@ -12,15 +12,19 @@ class TestGemspec < Test::Unit::TestCase
12
12
  end
13
13
  end
14
14
 
15
- context "Jeweler::GemSpec#write" do
15
+ context "#write" do
16
16
  setup do
17
17
  @spec = build_spec
18
- @helper = Jeweler::GemSpecHelper.new(@spec)
18
+ @helper = Jeweler::GemSpecHelper.new(@spec, File.dirname(__FILE__))
19
19
  FileUtils.rm_f(@helper.path)
20
20
 
21
21
  @helper.write
22
22
  end
23
23
 
24
+ teardown do
25
+ FileUtils.rm_f(@helper.path)
26
+ end
27
+
24
28
  should "create gemspec file" do
25
29
  assert File.exists?(@helper.path)
26
30
  end
@@ -0,0 +1,179 @@
1
+ require 'test_helper'
2
+
3
+ class TestGenerator < Test::Unit::TestCase
4
+ def build_generator(testing_framework = nil, options = {})
5
+ options[:testing_framework] = testing_framework
6
+ Jeweler::Generator.new('the-perfect-gem', options)
7
+ end
8
+
9
+ context "initialize" do
10
+ should "raise error if nil repo name given" do
11
+ assert_raise Jeweler::NoGitHubRepoNameGiven do
12
+ Jeweler::Generator.new(nil)
13
+ end
14
+ end
15
+
16
+ should "raise error if blank repo name given" do
17
+ assert_raise Jeweler::NoGitHubRepoNameGiven do
18
+ Jeweler::Generator.new("")
19
+ end
20
+ end
21
+
22
+ should "have shoulda as default framework" do
23
+ assert_equal :shoulda, build_generator.testing_framework
24
+ end
25
+
26
+ should "have repository name as default target dir" do
27
+ assert_equal 'the-perfect-gem', build_generator.target_dir
28
+ end
29
+
30
+ should "have TODO as default summary" do
31
+ assert_equal "TODO", build_generator.summary
32
+ end
33
+
34
+ should "not create repo by default" do
35
+ assert ! build_generator.should_create_repo
36
+ end
37
+
38
+ should "not use cucumber by default" do
39
+ assert ! build_generator.should_use_cucumber
40
+ end
41
+
42
+ should "raise error for invalid testing frameworks" do
43
+ assert_raise ArgumentError do
44
+ build_generator(:zomg_invalid)
45
+ end
46
+ end
47
+ end
48
+
49
+ context "test_or_spec" do
50
+ should "be test for shoulda" do
51
+ assert_equal 'test', build_generator(:shoulda).test_or_spec
52
+ end
53
+
54
+ should "be test for testunit" do
55
+ assert_equal 'test', build_generator(:testunit).test_or_spec
56
+ end
57
+
58
+ should "be test for minitest" do
59
+ assert_equal 'test', build_generator(:minitest).test_or_spec
60
+ end
61
+
62
+ should "be spec for bacon" do
63
+ assert_equal 'spec', build_generator(:bacon).test_or_spec
64
+ end
65
+
66
+ should "be spec for rspec" do
67
+ assert_equal 'spec', build_generator(:rspec).test_or_spec
68
+ end
69
+
70
+ should "be example for micronaut" do
71
+ assert_equal 'example', build_generator(:micronaut).test_or_spec
72
+ end
73
+ end
74
+
75
+ context "test_dir" do
76
+ should "be test for shoulda" do
77
+ assert_equal 'test', build_generator(:shoulda).test_dir
78
+ end
79
+
80
+ should "be test for testunit" do
81
+ assert_equal 'test', build_generator(:testunit).test_dir
82
+ end
83
+
84
+ should "be test for minitest" do
85
+ assert_equal 'test', build_generator(:minitest).test_dir
86
+ end
87
+
88
+ should "be spec for bacon" do
89
+ assert_equal 'spec', build_generator(:bacon).test_dir
90
+ end
91
+
92
+ should "be spec for rspec" do
93
+ assert_equal 'spec', build_generator(:rspec).test_dir
94
+ end
95
+
96
+ should "be examples for micronaut" do
97
+ assert_equal 'examples', build_generator(:micronaut).test_dir
98
+ end
99
+ end
100
+
101
+ context "default_task" do
102
+ should "be test for shoulda" do
103
+ assert_equal 'test', build_generator(:shoulda).default_task
104
+ end
105
+
106
+ should "be test for testunit" do
107
+ assert_equal 'test', build_generator(:testunit).default_task
108
+ end
109
+
110
+ should "be test for minitest" do
111
+ assert_equal 'test', build_generator(:minitest).default_task
112
+ end
113
+
114
+ should "be spec for bacon" do
115
+ assert_equal 'spec', build_generator(:bacon).default_task
116
+ end
117
+
118
+ should "be spec for rspec" do
119
+ assert_equal 'spec', build_generator(:rspec).default_task
120
+ end
121
+
122
+ should "be examples for micronaut" do
123
+ assert_equal 'examples', build_generator(:micronaut).default_task
124
+ end
125
+ end
126
+
127
+ context "feature_support_require" do
128
+ should "be test/unit/assertions for shoulda" do
129
+ assert_equal 'test/unit/assertions', build_generator(:shoulda).feature_support_require
130
+ end
131
+
132
+ should "be test/unit/assertions for testunit" do
133
+ assert_equal 'test/unit/assertions', build_generator(:testunit).feature_support_require
134
+ end
135
+
136
+ should "be mini/test for minitest" do
137
+ assert_equal 'mini/test', build_generator(:minitest).feature_support_require
138
+ end
139
+
140
+ should "be test/unit/assertions for bacon" do
141
+ assert_equal 'test/unit/assertions', build_generator(:bacon).feature_support_require
142
+ end
143
+
144
+ should "be spec/expectations for rspec" do
145
+ assert_equal 'spec/expectations', build_generator(:rspec).feature_support_require
146
+ end
147
+
148
+ should "be micronaut/expectations for micronaut" do
149
+ assert_equal 'micronaut/expectations', build_generator(:micronaut).feature_support_require
150
+ end
151
+ end
152
+
153
+ context "feature_support_extend" do
154
+ should "be Test::Unit::Assertions for shoulda" do
155
+ assert_equal 'Test::Unit::Assertions', build_generator(:shoulda).feature_support_extend
156
+ end
157
+
158
+ should "be Test::Unit::Assertions for testunit" do
159
+ assert_equal 'Test::Unit::Assertions', build_generator(:testunit).feature_support_extend
160
+ end
161
+
162
+ should "be Mini::Test::Assertions for minitest" do
163
+ assert_equal 'Mini::Test::Assertions', build_generator(:minitest).feature_support_extend
164
+ end
165
+
166
+ should "be Test::Unit::Assertions for bacon" do
167
+ assert_equal 'Test::Unit::Assertions', build_generator(:bacon).feature_support_extend
168
+ end
169
+
170
+ should "be nil for rspec" do
171
+ assert_equal nil, build_generator(:rspec).feature_support_extend
172
+ end
173
+
174
+ should "be Micronaut::Matchers for micronaut" do
175
+ assert_equal 'Micronaut::Matchers', build_generator(:micronaut).feature_support_extend
176
+ end
177
+ end
178
+
179
+ end
data/test/test_helper.rb CHANGED
@@ -1,14 +1,17 @@
1
1
  require 'test/unit'
2
2
 
3
3
  require 'rubygems'
4
- gem 'thoughtbot-shoulda'
5
4
  require 'shoulda'
6
- gem 'ruby-debug'
7
5
  require 'ruby-debug'
8
- gem 'mocha'
9
- require 'mocha'
6
+ require 'rr'
7
+ require 'output_catcher'
8
+ require 'time'
10
9
 
11
- require File.dirname(__FILE__) + '/shoulda_macros/jeweler_macros'
10
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
11
+ require 'jeweler'
12
+
13
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
14
+ require 'shoulda_macros/jeweler_macros'
12
15
 
13
16
  # Use vendored gem because of limited gem availability on runcoderun
14
17
  # This is loosely based on 'vendor everything'.
@@ -17,24 +20,9 @@ Dir[File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', '**')].each do |di
17
20
  $LOAD_PATH.unshift(lib) if File.directory?(lib)
18
21
  end
19
22
 
20
- require 'output_catcher'
21
- require 'time'
22
-
23
- $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
24
- $LOAD_PATH.unshift(File.dirname(__FILE__))
25
- require 'jeweler'
26
-
27
- # Fake out FileList from Rake
28
- class FileList
29
- def self.[](*args)
30
- TMP_DIR.entries - ['.','..','.DS_STORE']
31
- end
32
- end
33
-
34
- TMP_DIR = File.join(File.dirname(__FILE__), 'tmp')
35
- FileUtils.rm_f(TMP_DIR) # GAH, dirty hax. Somewhere isn't tearing up correctly, so do some cleanup first
36
-
37
23
  class Test::Unit::TestCase
24
+ include RR::Adapters::TestUnit unless include?(RR::Adapters::TestUnit)
25
+
38
26
  def catch_out(&block)
39
27
  OutputCatcher.catch_out do
40
28
  block.call
@@ -56,7 +44,7 @@ class Test::Unit::TestCase
56
44
  s.email = "josh@technicalpickles.com"
57
45
  s.homepage = "http://github.com/technicalpickles/jeweler"
58
46
  s.description = "Simple and opinionated helper for creating Rubygem projects on GitHub"
59
- s.authors = ["Josh Nichols", "Dan Croak"]
47
+ s.authors = ["Josh Nichols"]
60
48
  s.files = FileList[*files] unless files.empty?
61
49
  end
62
50
  end
data/test/test_jeweler.rb CHANGED
@@ -1,10 +1,11 @@
1
- require File.dirname(__FILE__) + '/test_helper'
1
+ require 'test_helper'
2
2
 
3
3
  class TestJeweler < Test::Unit::TestCase
4
4
 
5
5
  def setup
6
6
  @now = Time.now
7
- Time.stubs(:now).returns(@now)
7
+ stub(Time).now { @now }
8
+
8
9
  FileUtils.rm_rf("#{File.dirname(__FILE__)}/tmp")
9
10
  end
10
11
 
@@ -12,13 +13,13 @@ class TestJeweler < Test::Unit::TestCase
12
13
  FileUtils.rm_rf("#{File.dirname(__FILE__)}/tmp")
13
14
  end
14
15
 
15
- context "A jeweler without a VERSION.yml" do
16
+ context "Initializing jewewler in a blank directory" do
16
17
  setup do
17
18
  FileUtils.mkdir_p(tmp_dir)
18
19
  @jeweler = Jeweler.new(build_spec, tmp_dir)
19
20
  end
20
21
 
21
- should "not have VERSION.yml" do
22
+ should "not create a VERSION.yml" do
22
23
  assert ! File.exists?(File.join(tmp_dir, 'VERSION.yml'))
23
24
  end
24
25
  end
@@ -29,6 +30,7 @@ class TestJeweler < Test::Unit::TestCase
29
30
  FileUtils.cp_r(fixture_dir, tmp_dir)
30
31
 
31
32
  @jeweler = Jeweler.new(build_spec, tmp_dir)
33
+ @jeweler.output = StringIO.new
32
34
  end
33
35
 
34
36
  should_have_major_version 1
@@ -38,14 +40,14 @@ class TestJeweler < Test::Unit::TestCase
38
40
 
39
41
  context "bumping the patch version" do
40
42
  setup do
41
- @output = catch_out { @jeweler.bump_patch_version }
43
+ @jeweler.bump_patch_version
42
44
  end
43
45
  should_bump_version 1, 5, 3
44
46
  end
45
47
 
46
48
  context "bumping the minor version" do
47
49
  setup do
48
- @output = catch_out { @jeweler.bump_minor_version }
50
+ @jeweler.bump_minor_version
49
51
  end
50
52
 
51
53
  should_bump_version 1, 6, 0
@@ -53,13 +55,13 @@ class TestJeweler < Test::Unit::TestCase
53
55
 
54
56
  context "bumping the major version" do
55
57
  setup do
56
- @output = catch_out { @jeweler.bump_major_version}
58
+ @jeweler.bump_major_version
57
59
  end
58
60
 
59
61
  should_bump_version 2, 0, 0
60
62
  end
61
63
 
62
- should "should find files" do
64
+ should "should populate gemspec's files" do
63
65
  assert ! @jeweler.gemspec.files.empty?
64
66
  end
65
67
 
@@ -90,7 +92,8 @@ class TestJeweler < Test::Unit::TestCase
90
92
 
91
93
  context "writing the gemspec" do
92
94
  setup do
93
- @output = catch_out { @jeweler.write_gemspec }
95
+ @jeweler.write_gemspec
96
+ @output = @jeweler.output.string
94
97
  end
95
98
 
96
99
  should "create bar.gemspec" do
@@ -0,0 +1,90 @@
1
+ require 'test_helper'
2
+
3
+ class TestOptions < Test::Unit::TestCase
4
+
5
+ def self.should_have_testing_framework(testing_framework)
6
+ should "use #{testing_framework} for testing" do
7
+ assert_equal testing_framework.to_sym, @options[:testing_framework]
8
+ end
9
+ end
10
+
11
+ def setup_options(*arguments)
12
+ @options = Jeweler::Generator::Options.new(arguments)
13
+ end
14
+
15
+ def self.for_options(*options)
16
+ context options.join(' ') do
17
+ setup { setup_options *options }
18
+ yield
19
+ end
20
+ end
21
+
22
+ context "default options" do
23
+ setup { setup_options }
24
+ should_have_testing_framework :shoulda
25
+ should 'not create repository' do
26
+ assert ! @options[:create_repo]
27
+ end
28
+ end
29
+
30
+ for_options '--shoulda' do
31
+ should_have_testing_framework :shoulda
32
+ end
33
+
34
+ for_options "--bacon" do
35
+ should_have_testing_framework :bacon
36
+ end
37
+
38
+ for_options "--testunit" do
39
+ should_have_testing_framework :testunit
40
+ end
41
+
42
+ for_options '--minitest' do
43
+ should_have_testing_framework :minitest
44
+ end
45
+
46
+ for_options '--rspec' do
47
+ should_have_testing_framework :rspec
48
+ end
49
+
50
+ for_options '--micronaut' do
51
+ should_have_testing_framework :micronaut
52
+ end
53
+
54
+ for_options '--cucumber' do
55
+ should 'enable cucumber' do
56
+ assert_equal true, @options[:use_cucumber]
57
+ end
58
+ end
59
+
60
+ for_options '--create-repo' do
61
+ should 'create repository' do
62
+ assert @options[:create_repo]
63
+ end
64
+ end
65
+
66
+ for_options '--summary', 'zomg so awesome' do
67
+ should 'have summary zomg so awesome' do
68
+ assert_equal 'zomg so awesome', @options[:summary]
69
+ end
70
+ end
71
+
72
+ for_options '--directory', 'foo' do
73
+ should 'have directory foo' do
74
+ assert_equal 'foo', @options[:directory]
75
+ end
76
+ end
77
+
78
+ for_options '--help' do
79
+ should 'show help' do
80
+ assert @options[:show_help]
81
+ end
82
+ end
83
+
84
+ for_options '-h' do
85
+ should 'show help' do
86
+ assert @options[:show_help]
87
+ end
88
+ end
89
+
90
+ end
data/test/test_tasks.rb CHANGED
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/test_helper'
1
+ require 'test_helper'
2
2
 
3
3
  require 'rake'
4
4
  class TestTasks < Test::Unit::TestCase
@@ -9,7 +9,6 @@ class TestTasks < Test::Unit::TestCase
9
9
  Task.clear
10
10
 
11
11
  @jt = Jeweler::Tasks.new do |s|
12
-
13
12
  end
14
13
  end
15
14
 
@@ -25,12 +24,12 @@ class TestTasks < Test::Unit::TestCase
25
24
  assert Task.task_defined?(:build)
26
25
  assert Task.task_defined?(:install)
27
26
  assert Task.task_defined?(:gemspec)
27
+ assert Task.task_defined?(:build)
28
+ assert Task.task_defined?(:install)
28
29
  assert Task.task_defined?(:'gemspec:validate')
29
30
  assert Task.task_defined?(:'gemspec:generate')
30
31
  assert Task.task_defined?(:version)
31
32
  assert Task.task_defined?(:'version:write')
32
- assert Task.task_defined?(:'version:display')
33
- assert Task.task_defined?(:'version:bump')
34
33
  assert Task.task_defined?(:'version:bump:major')
35
34
  assert Task.task_defined?(:'version:bump:minor')
36
35
  assert Task.task_defined?(:'version:bump:patch')
@@ -1,30 +1,30 @@
1
- require File.dirname(__FILE__) + '/test_helper'
1
+ require 'test_helper'
2
2
 
3
- class TestVersion < Test::Unit::TestCase
3
+ class TestVersionHelper < Test::Unit::TestCase
4
4
 
5
5
  VERSION_TMP_DIR = File.dirname(__FILE__) + '/version_tmp'
6
6
 
7
7
  def self.should_have_version(major, minor, patch)
8
8
  should "have major version #{major}" do
9
- assert_equal major, @version.major
9
+ assert_equal major, @version_helper.major
10
10
  end
11
11
 
12
12
  should "have minor version #{minor}" do
13
- assert_equal minor, @version.minor
13
+ assert_equal minor, @version_helper.minor
14
14
  end
15
15
 
16
16
  should "have patch version #{patch}" do
17
- assert_equal patch, @version.patch
17
+ assert_equal patch, @version_helper.patch
18
18
  end
19
19
 
20
20
  version_s = "#{major}.#{minor}.#{patch}"
21
21
  should "render string as #{version_s.inspect}" do
22
- assert_equal version_s, @version.to_s
22
+ assert_equal version_s, @version_helper.to_s
23
23
  end
24
24
 
25
25
  version_hash = {:major => major, :minor => minor, :patch => patch}
26
26
  should "render hash as #{version_hash.inspect}" do
27
- assert_equal version_hash, @version.to_hash
27
+ assert_equal version_hash, @version_helper.to_hash
28
28
  end
29
29
 
30
30
  end
@@ -36,23 +36,23 @@ class TestVersion < Test::Unit::TestCase
36
36
 
37
37
  build_version_yml VERSION_TMP_DIR, 3, 5, 4
38
38
 
39
- @version = Jeweler::Version.new VERSION_TMP_DIR
39
+ @version_helper = Jeweler::VersionHelper.new VERSION_TMP_DIR
40
40
  end
41
41
 
42
42
  should_have_version 3, 5, 4
43
43
 
44
44
  context "bumping major version" do
45
- setup { @version.bump_major }
45
+ setup { @version_helper.bump_major }
46
46
  should_have_version 4, 0, 0
47
47
  end
48
48
 
49
49
  context "bumping the minor version" do
50
- setup { @version.bump_minor }
50
+ setup { @version_helper.bump_minor }
51
51
  should_have_version 3, 6, 0
52
52
  end
53
53
 
54
54
  context "bumping the patch version" do
55
- setup { @version.bump_patch }
55
+ setup { @version_helper.bump_patch }
56
56
  should_have_version 3, 5, 5
57
57
  end
58
58
  end
@@ -65,14 +65,14 @@ class TestVersion < Test::Unit::TestCase
65
65
 
66
66
  should "not raise error if the VERSION.yml doesn't exist" do
67
67
  assert_nothing_raised Jeweler::VersionYmlError do
68
- Jeweler::Version.new(VERSION_TMP_DIR)
68
+ Jeweler::VersionHelper.new(VERSION_TMP_DIR)
69
69
  end
70
70
  end
71
71
 
72
72
  context "setting an initial version" do
73
73
  setup do
74
- @version = Jeweler::Version.new(VERSION_TMP_DIR)
75
- @version.update_to 0, 0, 1
74
+ @version_helper = Jeweler::VersionHelper.new(VERSION_TMP_DIR)
75
+ @version_helper.update_to 0, 0, 1
76
76
  end
77
77
 
78
78
  should_have_version 0, 0, 1
@@ -82,7 +82,7 @@ class TestVersion < Test::Unit::TestCase
82
82
 
83
83
  context "outputting" do
84
84
  setup do
85
- @version.write
85
+ @version_helper.write
86
86
  end
87
87
 
88
88
  should "create VERSION.yml" do
@@ -91,7 +91,7 @@ class TestVersion < Test::Unit::TestCase
91
91
 
92
92
  context "re-reading VERSION.yml" do
93
93
  setup do
94
- @version = Jeweler::Version.new(VERSION_TMP_DIR)
94
+ @version_helper = Jeweler::VersionHelper.new(VERSION_TMP_DIR)
95
95
  end
96
96
 
97
97
  should_have_version 0, 0, 1