technicalpickles-jeweler 0.9.1 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/ChangeLog.markdown +6 -0
  2. data/README.markdown +67 -2
  3. data/Rakefile +31 -3
  4. data/VERSION.yml +2 -2
  5. data/lib/jeweler.rb +30 -31
  6. data/lib/jeweler/commands.rb +2 -0
  7. data/lib/jeweler/commands/build_gem.rb +9 -0
  8. data/lib/jeweler/commands/install_gem.rb +7 -0
  9. data/lib/jeweler/commands/release.rb +13 -0
  10. data/lib/jeweler/commands/release_to_rubyforge.rb +51 -0
  11. data/lib/jeweler/commands/setup_rubyforge.rb +38 -0
  12. data/lib/jeweler/commands/validate_gemspec.rb +9 -0
  13. data/lib/jeweler/commands/version/base.rb +11 -0
  14. data/lib/jeweler/commands/write_gemspec.rb +13 -0
  15. data/lib/jeweler/errors.rb +13 -1
  16. data/lib/jeweler/generator.rb +3 -1
  17. data/lib/jeweler/generator/options.rb +4 -0
  18. data/lib/jeweler/tasks.rb +29 -5
  19. data/lib/jeweler/templates/Rakefile +46 -9
  20. data/test/fixtures/existing-project-with-version/LICENSE +20 -0
  21. data/test/fixtures/existing-project-with-version/README.rdoc +7 -0
  22. data/test/fixtures/existing-project-with-version/Rakefile +82 -0
  23. data/test/fixtures/existing-project-with-version/VERSION.yml +4 -0
  24. data/test/fixtures/existing-project-with-version/existing-project-with-version.gemspec +29 -0
  25. data/test/fixtures/existing-project-with-version/lib/existing_project_with_version.rb +0 -0
  26. data/test/fixtures/existing-project-with-version/test/existing_project_with_version_test.rb +7 -0
  27. data/test/fixtures/existing-project-with-version/test/test_helper.rb +10 -0
  28. data/test/geminstaller.yml +12 -0
  29. data/test/jeweler/commands/test_build_gem.rb +20 -1
  30. data/test/jeweler/commands/test_install_gem.rb +21 -0
  31. data/test/jeweler/commands/test_release.rb +30 -0
  32. data/test/jeweler/commands/test_release_to_rubyforge.rb +157 -0
  33. data/test/jeweler/commands/test_setup_rubyforge.rb +88 -0
  34. data/test/jeweler/commands/test_validate_gemspec.rb +27 -0
  35. data/test/jeweler/commands/test_write_gemspec.rb +34 -0
  36. data/test/jeweler/commands/version/test_base.rb +32 -0
  37. data/test/jeweler/commands/version/test_bump_major.rb +1 -0
  38. data/test/test_application.rb +4 -0
  39. data/test/test_generator.rb +4 -0
  40. data/test/test_helper.rb +75 -8
  41. data/test/test_jeweler.rb +137 -96
  42. data/test/test_options.rb +6 -0
  43. data/test/test_tasks.rb +2 -0
  44. metadata +26 -4
@@ -0,0 +1,21 @@
1
+ require 'test_helper'
2
+
3
+ class Jeweler
4
+ module Commands
5
+ class TestInstallGem < Test::Unit::TestCase
6
+ build_command_context "build for jeweler" do
7
+ setup do
8
+ @command = Jeweler::Commands::InstallGem.build_for(@jeweler)
9
+ end
10
+
11
+ should "assign gemspec helper" do
12
+ assert_equal @gemspec_helper, @command.gemspec_helper
13
+ end
14
+
15
+ should "assign output" do
16
+ assert_equal @output, @command.output
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -145,6 +145,36 @@ class Jeweler
145
145
  assert_received(@repo) {|repo| repo.push('origin', 'v1.2.3')}
146
146
  end
147
147
  end
148
+
149
+ build_command_context "building from jeweler" do
150
+ setup do
151
+ @command = Jeweler::Commands::Release.build_for(@jeweler)
152
+ end
153
+
154
+ should "assign gemspec" do
155
+ assert_same @gemspec, @command.gemspec
156
+ end
157
+
158
+ should "assign version" do
159
+ assert_same @version, @command.version
160
+ end
161
+
162
+ should "assign repo" do
163
+ assert_same @repo, @command.repo
164
+ end
165
+
166
+ should "assign output" do
167
+ assert_same @output, @command.output
168
+ end
169
+
170
+ should "assign gemspec_helper" do
171
+ assert_same @gemspec_helper, @command.gemspec_helper
172
+ end
173
+
174
+ should "assign base_dir" do
175
+ assert_same @base_dir, @command.base_dir
176
+ end
177
+ end
148
178
  end
149
179
  end
150
180
  end
@@ -0,0 +1,157 @@
1
+ require 'test_helper'
2
+
3
+ class Jeweler
4
+ module Commands
5
+ class TestReleaseToRubyforge < Test::Unit::TestCase
6
+ def self.subject
7
+ Jeweler::Commands::ReleaseToRubyforge.new
8
+ end
9
+
10
+ rubyforge_command_context "rubyforge_project is defined in gemspec and package exists on rubyforge" do
11
+ setup do
12
+ stub(@rubyforge).configure
13
+ stub(@rubyforge).login
14
+ stub(@rubyforge).add_release("MyRubyForgeProjectName", "zomg", "1.2.3", "pkg/zomg-1.2.3.gem")
15
+
16
+ stub(@gemspec).description {"The zomg gem rocks."}
17
+ stub(@gemspec).rubyforge_project {"MyRubyForgeProjectName"}
18
+ stub(@gemspec).name {"zomg"}
19
+
20
+ stub(@gemspec_helper).write
21
+ stub(@gemspec_helper).gem_path {'pkg/zomg-1.2.3.gem'}
22
+ stub(@gemspec_helper).update_version('1.2.3')
23
+
24
+ @command.version = '1.2.3'
25
+
26
+ @command.run
27
+ end
28
+
29
+ should "configure" do
30
+ assert_received(@rubyforge) {|rubyforge| rubyforge.configure }
31
+ end
32
+
33
+ should "login" do
34
+ assert_received(@rubyforge) {|rubyforge| rubyforge.login }
35
+ end
36
+
37
+ should "set release notes" do
38
+ assert_equal "The zomg gem rocks.", @rubyforge.userconfig["release_notes"]
39
+ end
40
+
41
+ should "set preformatted to true" do
42
+ assert_equal true, @rubyforge.userconfig['preformatted']
43
+ end
44
+
45
+ should "add release" do
46
+ assert_received(@rubyforge) {|rubyforge| rubyforge.add_release("MyRubyForgeProjectName", "zomg", "1.2.3", "pkg/zomg-1.2.3.gem") }
47
+ end
48
+ end
49
+
50
+ rubyforge_command_context "rubyforge_project is defined in gemspec and package does not exist on rubyforge" do
51
+ setup do
52
+ stub(@rubyforge).configure
53
+ stub(@rubyforge).login
54
+ stub(@rubyforge).scrape_config
55
+ stub(@rubyforge).add_release("MyRubyForgeProjectName", "zomg", "1.2.3", "pkg/zomg-1.2.3.gem") {
56
+ raise "no <package_id> configured for <zomg>"
57
+ }
58
+
59
+ stub(@gemspec).description {"The zomg gem rocks."}
60
+ stub(@gemspec).rubyforge_project {"MyRubyForgeProjectName"}
61
+ stub(@gemspec).name {"zomg"}
62
+
63
+ stub(@gemspec_helper).write
64
+ stub(@gemspec_helper).gem_path {'pkg/zomg-1.2.3.gem'}
65
+ stub(@gemspec_helper).update_version('1.2.3')
66
+
67
+ @command.version = '1.2.3'
68
+ end
69
+
70
+ should "raise MissingRubyForgePackageError" do
71
+ assert_raises Jeweler::MissingRubyForgePackageError do
72
+ @command.run
73
+ end
74
+ end
75
+ end
76
+
77
+ rubyforge_command_context "rubyforge_project is not defined in gemspec" do
78
+ setup do
79
+ stub(@rubyforge).configure
80
+ stub(@rubyforge).login
81
+ stub(@rubyforge).add_release(nil, "zomg", "1.2.3", "pkg/zomg-1.2.3.gem")
82
+
83
+ stub(@gemspec).description {"The zomg gem rocks."}
84
+ stub(@gemspec).rubyforge_project { nil }
85
+ stub(@gemspec).name {"zomg"}
86
+
87
+ stub(@gemspec_helper).write
88
+ stub(@gemspec_helper).gem_path {'pkg/zomg-1.2.3.gem'}
89
+ stub(@gemspec_helper).update_version('1.2.3')
90
+
91
+ @command.version = '1.2.3'
92
+ end
93
+
94
+ should "raise NoRubyForgeProjectConfigured" do
95
+ assert_raises Jeweler::NoRubyForgeProjectInGemspecError do
96
+ @command.run
97
+ end
98
+ end
99
+ end
100
+
101
+ rubyforge_command_context "after running when rubyforge_project is not defined in ~/.rubyforge/auto_config.yml" do
102
+ setup do
103
+ stub(@rubyforge).configure
104
+ stub(@rubyforge).login
105
+ stub(@rubyforge).add_release("some_project_that_doesnt_exist", "zomg", "1.2.3", "pkg/zomg-1.2.3.gem") do
106
+ raise RuntimeError, "no <group_id> configured for <some_project_that_doesnt_exist>"
107
+ end
108
+
109
+ @rubyforge.autoconfig['package_ids'] = { 'zomg' => 1234 }
110
+
111
+ stub(@gemspec).description {"The zomg gem rocks."}
112
+ stub(@gemspec).rubyforge_project { "some_project_that_doesnt_exist" }
113
+ stub(@gemspec).name {"zomg"}
114
+
115
+ stub(@gemspec_helper).write
116
+ stub(@gemspec_helper).gem_path {'pkg/zomg-1.2.3.gem'}
117
+ stub(@gemspec_helper).update_version('1.2.3')
118
+
119
+ @command.version = '1.2.3'
120
+ end
121
+
122
+ should "raise RubyForgeProjectNotConfiguredError" do
123
+ assert_raises RubyForgeProjectNotConfiguredError do
124
+ @command.run
125
+ end
126
+ end
127
+ end
128
+
129
+ build_command_context "build for jeweler" do
130
+ setup do
131
+ @command = Jeweler::Commands::ReleaseToRubyforge.build_for(@jeweler)
132
+ end
133
+
134
+ should "assign gemspec helper" do
135
+ assert_equal @gemspec_helper, @command.gemspec_helper
136
+ end
137
+
138
+ should "assign gemspec" do
139
+ assert_equal @gemspec, @command.gemspec
140
+ end
141
+
142
+ should "assign version" do
143
+ assert_equal @version, @command.version
144
+ end
145
+
146
+ should "assign output" do
147
+ assert_equal @output, @command.output
148
+ end
149
+
150
+ should "assign rubyforge" do
151
+ assert_equal @rubyforge, @command.rubyforge
152
+ end
153
+ end
154
+
155
+ end
156
+ end
157
+ end
@@ -0,0 +1,88 @@
1
+ require 'test_helper'
2
+
3
+ class Jeweler
4
+ module Commands
5
+ class TestSetupRubyforge < Test::Unit::TestCase
6
+ def self.subject
7
+ Jeweler::Commands::SetupRubyforge.new
8
+ end
9
+
10
+ rubyforge_command_context "rubyforge_project is defined in gemspec and package exists on rubyforge" do
11
+ setup do
12
+ stub(@rubyforge).configure
13
+ stub(@rubyforge).login
14
+ stub(@rubyforge).create_package('myproject', 'zomg')
15
+
16
+ stub(@gemspec).name { 'zomg' }
17
+ stub(@gemspec).rubyforge_project { 'myproject' }
18
+
19
+ @command.run
20
+ end
21
+
22
+ should "configure rubyforge" do
23
+ assert_received(@rubyforge) {|rubyforge| rubyforge.configure}
24
+ end
25
+
26
+ should "login to rubyforge" do
27
+ assert_received(@rubyforge) {|rubyforge| rubyforge.login}
28
+ end
29
+
30
+ should "create zomg package to myproject on rubyforge" do
31
+ assert_received(@rubyforge) {|rubyforge| rubyforge.create_package('myproject', 'zomg') }
32
+ end
33
+ end
34
+
35
+ rubyforge_command_context "rubyforge_project not configured" do
36
+ setup do
37
+ stub(@gemspec).name { 'zomg' }
38
+ stub(@gemspec).rubyforge_project { nil }
39
+ end
40
+
41
+ should "raise NoRubyForgeProjectConfigured" do
42
+ assert_raises Jeweler::NoRubyForgeProjectInGemspecError do
43
+ @command.run
44
+ end
45
+ end
46
+ end
47
+
48
+ rubyforge_command_context "rubyforge project doesn't exist or not setup in ~/.rubyforge/autoconfig.yml" do
49
+ setup do
50
+ stub(@rubyforge).configure
51
+ stub(@rubyforge).login
52
+ stub(@rubyforge).create_package('some_project_that_doesnt_exist', 'zomg')do
53
+ raise RuntimeError, "no <group_id> configured for <some_project_that_doesnt_exist>"
54
+ end
55
+
56
+ stub(@gemspec).name { 'zomg' }
57
+ stub(@gemspec).rubyforge_project { 'some_project_that_doesnt_exist' }
58
+ end
59
+
60
+ should "raise RubyForgeProjectNotConfiguredError" do
61
+ assert_raises RubyForgeProjectNotConfiguredError do
62
+ @command.run
63
+ end
64
+ end
65
+
66
+ end
67
+
68
+ build_command_context "build for jeweler" do
69
+ setup do
70
+ @command = Jeweler::Commands::SetupRubyforge.build_for(@jeweler)
71
+ end
72
+
73
+ should "assign gemspec" do
74
+ assert_equal @gemspec, @command.gemspec
75
+ end
76
+
77
+ should "assign output" do
78
+ assert_equal @output, @command.output
79
+ end
80
+
81
+ should "assign rubyforge" do
82
+ assert_equal @rubyforge, @command.rubyforge
83
+ end
84
+ end
85
+
86
+ end
87
+ end
88
+ end
@@ -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
@@ -53,6 +53,40 @@ class Jeweler
53
53
 
54
54
  end
55
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
+
56
90
  end
57
91
  end
58
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
+
@@ -14,6 +14,7 @@ class Jeweler
14
14
  command.update_version
15
15
  end
16
16
  end
17
+
17
18
  end
18
19
  end
19
20
  end
@@ -48,6 +48,10 @@ class TestApplication < Test::Unit::TestCase
48
48
  end
49
49
 
50
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
+
51
55
  Jeweler::Generator.new(name, options)
52
56
  end
53
57
 
@@ -2,6 +2,10 @@ require 'test_helper'
2
2
 
3
3
  class TestGenerator < Test::Unit::TestCase
4
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
+
5
9
  options[:testing_framework] = testing_framework
6
10
  Jeweler::Generator.new('the-perfect-gem', options)
7
11
  end
data/test/test_helper.rb CHANGED
@@ -2,9 +2,11 @@ require 'test/unit'
2
2
 
3
3
  require 'rubygems'
4
4
  require 'shoulda'
5
- require 'ruby-debug'
5
+ begin
6
+ require 'ruby-debug'
7
+ rescue LoadError
8
+ end
6
9
  require 'rr'
7
- require 'output_catcher'
8
10
  require 'time'
9
11
 
10
12
  $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
@@ -20,15 +22,18 @@ Dir[File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', '**')].each do |di
20
22
  $LOAD_PATH.unshift(lib) if File.directory?(lib)
21
23
  end
22
24
 
25
+ class RubyForgeStub
26
+ attr_accessor :userconfig, :autoconfig
27
+
28
+ def initialize
29
+ @userconfig = {}
30
+ @autoconfig = {}
31
+ end
32
+ end
33
+
23
34
  class Test::Unit::TestCase
24
35
  include RR::Adapters::TestUnit unless include?(RR::Adapters::TestUnit)
25
36
 
26
- def catch_out(&block)
27
- OutputCatcher.catch_out do
28
- block.call
29
- end
30
- end
31
-
32
37
  def fixture_dir
33
38
  File.join(File.dirname(__FILE__), 'fixtures', 'bar')
34
39
  end
@@ -48,4 +53,66 @@ class Test::Unit::TestCase
48
53
  s.files = FileList[*files] unless files.empty?
49
54
  end
50
55
  end
56
+
57
+ def self.rubyforge_command_context(description, &block)
58
+ context description do
59
+ setup do
60
+ @command = eval(self.class.name.gsub(/::Test/, '::')).new
61
+
62
+ if @command.respond_to? :gemspec=
63
+ @gemspec = Object.new
64
+ @command.gemspec = @gemspec
65
+ end
66
+
67
+ if @command.respond_to? :gemspec_helper=
68
+ @gemspec_helper = Object.new
69
+ @command.gemspec_helper = @gemspec_helper
70
+ end
71
+
72
+ if @command.respond_to? :rubyforge=
73
+ @rubyforge = RubyForgeStub.new
74
+ @command.rubyforge = @rubyforge
75
+ end
76
+
77
+ if @command.respond_to? :output
78
+ @output = StringIO.new
79
+ @command.output = @output
80
+ end
81
+ end
82
+
83
+ context "", &block
84
+ end
85
+ end
86
+
87
+ def self.build_command_context(description, &block)
88
+ context description do
89
+ setup do
90
+
91
+ @repo = Object.new
92
+ @version_helper = Object.new
93
+ @gemspec = Object.new
94
+ @commit = Object.new
95
+ @version = Object.new
96
+ @output = Object.new
97
+ @base_dir = Object.new
98
+ @gemspec_helper = Object.new
99
+ @rubyforge = Object.new
100
+
101
+ @jeweler = Object.new
102
+
103
+ stub(@jeweler).repo { @repo }
104
+ stub(@jeweler).version_helper { @version_helper }
105
+ stub(@jeweler).gemspec { @gemspec }
106
+ stub(@jeweler).commit { @commit }
107
+ stub(@jeweler).version { @version }
108
+ stub(@jeweler).output { @output }
109
+ stub(@jeweler).gemspec_helper { @gemspec_helper }
110
+ stub(@jeweler).base_dir { @base_dir }
111
+ stub(@jeweler).rubyforge { @rubyforge }
112
+ end
113
+
114
+ context "", &block
115
+ end
116
+
117
+ end
51
118
  end