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,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
@@ -0,0 +1,32 @@
1
+ require 'test_helper'
2
+
3
+ class Jeweler
4
+ module Commands
5
+ module Version
6
+ class TestBase < Test::Unit::TestCase
7
+ build_command_context "build for jeweler" do
8
+ setup do
9
+ @command = Jeweler::Commands::Version::Base.build_for(@jeweler)
10
+ end
11
+
12
+ should "assign repo" do
13
+ assert_equal @repo, @command.repo
14
+ end
15
+
16
+ should "assign version_helper" do
17
+ assert_equal @version_helper, @command.version_helper
18
+ end
19
+
20
+ should "assign gemspec" do
21
+ assert_equal @gemspec, @command.gemspec
22
+ end
23
+
24
+ should"assign commit" do
25
+ assert_equal @commit, @command.commit
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+
@@ -0,0 +1,22 @@
1
+ require 'test_helper'
2
+
3
+ class Jeweler
4
+ module Commands
5
+ module Version
6
+ class TestBumpMajor < Test::Unit::TestCase
7
+
8
+ should "call bump_major on version_helper in update_version" do
9
+ mock(version_helper = Object.new).bump_major
10
+
11
+ command = Jeweler::Commands::Version::BumpMajor.new
12
+ command.version_helper = version_helper
13
+
14
+ command.update_version
15
+ end
16
+ end
17
+
18
+ end
19
+ end
20
+ end
21
+
22
+
@@ -0,0 +1,19 @@
1
+ require 'test_helper'
2
+
3
+ class Jeweler
4
+ module Commands
5
+ module Version
6
+ class TestBumpMinor < Test::Unit::TestCase
7
+
8
+ should "call bump_minor on version_helper in update_version" do
9
+ mock(version_helper = Object.new).bump_minor
10
+
11
+ command = Jeweler::Commands::Version::BumpMinor.new
12
+ command.version_helper = version_helper
13
+
14
+ command.update_version
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,20 @@
1
+ require 'test_helper'
2
+
3
+ class Jeweler
4
+ module Commands
5
+ module Version
6
+ class TestBumpPatch < Test::Unit::TestCase
7
+
8
+ should "call bump_patch on version_helper in update_version" do
9
+ mock(version_helper = Object.new).bump_patch
10
+
11
+ command = Jeweler::Commands::Version::BumpPatch.new
12
+ command.version_helper = version_helper
13
+
14
+ command.update_version
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+
@@ -0,0 +1,23 @@
1
+ require 'test_helper'
2
+
3
+ class Jeweler
4
+ module Commands
5
+ module Version
6
+ class TestWrite < Test::Unit::TestCase
7
+
8
+ should "call write_version on version_helper in update_version" do
9
+ mock(version_helper = Object.new).update_to 1, 2, 3
10
+
11
+ command = Jeweler::Commands::Version::Write.new
12
+ command.version_helper = version_helper
13
+ command.major = 1
14
+ command.minor = 2
15
+ command.patch = 3
16
+
17
+ command.update_version
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+
@@ -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
@@ -0,0 +1,113 @@
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
+ stub.instance_of(Git::Lib).parse_config '~/.gitconfig' do
52
+ {'user.name' => 'John Doe', 'user.email' => 'john@example.com', 'github.user' => 'johndoe', 'github.token' => 'yyz'}
53
+ end
54
+
55
+ Jeweler::Generator.new(name, options)
56
+ end
57
+
58
+ context "called with -h" do
59
+ setup do
60
+ @generator = build_generator
61
+ stub(@generator).run
62
+ stub(Jeweler::Generator).new { raise "Shouldn't have made this far"}
63
+
64
+ assert_nothing_raised do
65
+ @result = run_application("-h")
66
+ end
67
+ end
68
+
69
+ should_exit_with_code 1
70
+
71
+ should 'display usage on stderr' do
72
+ assert_match 'Usage:', @stderr
73
+ end
74
+
75
+ should 'not display anything on stdout' do
76
+ assert_equal '', @stdout.squeeze.strip
77
+ end
78
+ end
79
+
80
+ context "when called with repo name" do
81
+ setup do
82
+ @options = {:testing_framework => :shoulda}
83
+ @generator = build_generator('zomg', @options)
84
+
85
+ stub(@generator).run
86
+ stub(Jeweler::Generator).new { @generator }
87
+ end
88
+
89
+ should 'return exit code 0' do
90
+ result = run_application("zomg")
91
+ assert_equal 0, result
92
+ end
93
+
94
+ should 'create generator with repo name and no options' do
95
+ run_application("zomg")
96
+
97
+ assert_received Jeweler::Generator do |subject|
98
+ subject.new('zomg', @options)
99
+ end
100
+ end
101
+
102
+ should 'run generator' do
103
+ run_application("zomg")
104
+
105
+ assert_received(@generator) {|subject| subject.run }
106
+ end
107
+
108
+ should 'not display usage on stderr' do
109
+ assert_no_match /Usage:/, @stderr
110
+ end
111
+ end
112
+
113
+ end
@@ -0,0 +1,36 @@
1
+ require 'test_helper'
2
+
3
+ class TestGemspecHelper < Test::Unit::TestCase
4
+ context "given a gemspec" do
5
+ setup do
6
+ @spec = build_spec
7
+ @helper = Jeweler::GemSpecHelper.new(@spec, File.dirname(__FILE__))
8
+ end
9
+
10
+ should 'have sane gemspec path' do
11
+ assert_equal "test/#{@spec.name}.gemspec", @helper.path
12
+ end
13
+ end
14
+
15
+ context "#write" do
16
+ setup do
17
+ @spec = build_spec
18
+ @helper = Jeweler::GemSpecHelper.new(@spec, File.dirname(__FILE__))
19
+ FileUtils.rm_f(@helper.path)
20
+
21
+ @helper.write
22
+ end
23
+
24
+ teardown do
25
+ FileUtils.rm_f(@helper.path)
26
+ end
27
+
28
+ should "create gemspec file" do
29
+ assert File.exists?(@helper.path)
30
+ end
31
+
32
+ should "make valid spec" do
33
+ assert @helper.valid?
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,183 @@
1
+ require 'test_helper'
2
+
3
+ class TestGenerator < Test::Unit::TestCase
4
+ def build_generator(testing_framework = nil, options = {})
5
+ stub.instance_of(Git::Lib).parse_config '~/.gitconfig' do
6
+ {'user.name' => 'John Doe', 'user.email' => 'john@example.com', 'github.user' => 'johndoe', 'github.token' => 'yyz'}
7
+ end
8
+
9
+ options[:testing_framework] = testing_framework
10
+ Jeweler::Generator.new('the-perfect-gem', options)
11
+ end
12
+
13
+ context "initialize" do
14
+ should "raise error if nil repo name given" do
15
+ assert_raise Jeweler::NoGitHubRepoNameGiven do
16
+ Jeweler::Generator.new(nil)
17
+ end
18
+ end
19
+
20
+ should "raise error if blank repo name given" do
21
+ assert_raise Jeweler::NoGitHubRepoNameGiven do
22
+ Jeweler::Generator.new("")
23
+ end
24
+ end
25
+
26
+ should "have shoulda as default framework" do
27
+ assert_equal :shoulda, build_generator.testing_framework
28
+ end
29
+
30
+ should "have repository name as default target dir" do
31
+ assert_equal 'the-perfect-gem', build_generator.target_dir
32
+ end
33
+
34
+ should "have TODO as default summary" do
35
+ assert_equal "TODO", build_generator.summary
36
+ end
37
+
38
+ should "not create repo by default" do
39
+ assert ! build_generator.should_create_repo
40
+ end
41
+
42
+ should "not use cucumber by default" do
43
+ assert ! build_generator.should_use_cucumber
44
+ end
45
+
46
+ should "raise error for invalid testing frameworks" do
47
+ assert_raise ArgumentError do
48
+ build_generator(:zomg_invalid)
49
+ end
50
+ end
51
+ end
52
+
53
+ context "test_or_spec" do
54
+ should "be test for shoulda" do
55
+ assert_equal 'test', build_generator(:shoulda).test_or_spec
56
+ end
57
+
58
+ should "be test for testunit" do
59
+ assert_equal 'test', build_generator(:testunit).test_or_spec
60
+ end
61
+
62
+ should "be test for minitest" do
63
+ assert_equal 'test', build_generator(:minitest).test_or_spec
64
+ end
65
+
66
+ should "be spec for bacon" do
67
+ assert_equal 'spec', build_generator(:bacon).test_or_spec
68
+ end
69
+
70
+ should "be spec for rspec" do
71
+ assert_equal 'spec', build_generator(:rspec).test_or_spec
72
+ end
73
+
74
+ should "be example for micronaut" do
75
+ assert_equal 'example', build_generator(:micronaut).test_or_spec
76
+ end
77
+ end
78
+
79
+ context "test_dir" do
80
+ should "be test for shoulda" do
81
+ assert_equal 'test', build_generator(:shoulda).test_dir
82
+ end
83
+
84
+ should "be test for testunit" do
85
+ assert_equal 'test', build_generator(:testunit).test_dir
86
+ end
87
+
88
+ should "be test for minitest" do
89
+ assert_equal 'test', build_generator(:minitest).test_dir
90
+ end
91
+
92
+ should "be spec for bacon" do
93
+ assert_equal 'spec', build_generator(:bacon).test_dir
94
+ end
95
+
96
+ should "be spec for rspec" do
97
+ assert_equal 'spec', build_generator(:rspec).test_dir
98
+ end
99
+
100
+ should "be examples for micronaut" do
101
+ assert_equal 'examples', build_generator(:micronaut).test_dir
102
+ end
103
+ end
104
+
105
+ context "default_task" do
106
+ should "be test for shoulda" do
107
+ assert_equal 'test', build_generator(:shoulda).default_task
108
+ end
109
+
110
+ should "be test for testunit" do
111
+ assert_equal 'test', build_generator(:testunit).default_task
112
+ end
113
+
114
+ should "be test for minitest" do
115
+ assert_equal 'test', build_generator(:minitest).default_task
116
+ end
117
+
118
+ should "be spec for bacon" do
119
+ assert_equal 'spec', build_generator(:bacon).default_task
120
+ end
121
+
122
+ should "be spec for rspec" do
123
+ assert_equal 'spec', build_generator(:rspec).default_task
124
+ end
125
+
126
+ should "be examples for micronaut" do
127
+ assert_equal 'examples', build_generator(:micronaut).default_task
128
+ end
129
+ end
130
+
131
+ context "feature_support_require" do
132
+ should "be test/unit/assertions for shoulda" do
133
+ assert_equal 'test/unit/assertions', build_generator(:shoulda).feature_support_require
134
+ end
135
+
136
+ should "be test/unit/assertions for testunit" do
137
+ assert_equal 'test/unit/assertions', build_generator(:testunit).feature_support_require
138
+ end
139
+
140
+ should "be mini/test for minitest" do
141
+ assert_equal 'mini/test', build_generator(:minitest).feature_support_require
142
+ end
143
+
144
+ should "be test/unit/assertions for bacon" do
145
+ assert_equal 'test/unit/assertions', build_generator(:bacon).feature_support_require
146
+ end
147
+
148
+ should "be spec/expectations for rspec" do
149
+ assert_equal 'spec/expectations', build_generator(:rspec).feature_support_require
150
+ end
151
+
152
+ should "be micronaut/expectations for micronaut" do
153
+ assert_equal 'micronaut/expectations', build_generator(:micronaut).feature_support_require
154
+ end
155
+ end
156
+
157
+ context "feature_support_extend" do
158
+ should "be Test::Unit::Assertions for shoulda" do
159
+ assert_equal 'Test::Unit::Assertions', build_generator(:shoulda).feature_support_extend
160
+ end
161
+
162
+ should "be Test::Unit::Assertions for testunit" do
163
+ assert_equal 'Test::Unit::Assertions', build_generator(:testunit).feature_support_extend
164
+ end
165
+
166
+ should "be Mini::Test::Assertions for minitest" do
167
+ assert_equal 'Mini::Test::Assertions', build_generator(:minitest).feature_support_extend
168
+ end
169
+
170
+ should "be Test::Unit::Assertions for bacon" do
171
+ assert_equal 'Test::Unit::Assertions', build_generator(:bacon).feature_support_extend
172
+ end
173
+
174
+ should "be nil for rspec" do
175
+ assert_equal nil, build_generator(:rspec).feature_support_extend
176
+ end
177
+
178
+ should "be Micronaut::Matchers for micronaut" do
179
+ assert_equal 'Micronaut::Matchers', build_generator(:micronaut).feature_support_extend
180
+ end
181
+ end
182
+
183
+ end