dima-jeweler 0.9.2
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.
- data/ChangeLog.markdown +58 -0
- data/LICENSE +20 -0
- data/README.markdown +103 -0
- data/Rakefile +61 -0
- data/TODO +11 -0
- data/VERSION.yml +4 -0
- data/bin/jeweler +8 -0
- data/lib/jeweler.rb +161 -0
- data/lib/jeweler/commands.rb +11 -0
- data/lib/jeweler/commands/build_gem.rb +22 -0
- data/lib/jeweler/commands/install_gem.rb +19 -0
- data/lib/jeweler/commands/release.rb +46 -0
- data/lib/jeweler/commands/release_to_rubyforge.rb +28 -0
- data/lib/jeweler/commands/validate_gemspec.rb +21 -0
- data/lib/jeweler/commands/version/base.rb +30 -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 +26 -0
- data/lib/jeweler/errors.rb +8 -0
- data/lib/jeweler/gemspec_helper.rb +51 -0
- data/lib/jeweler/generator.rb +345 -0
- data/lib/jeweler/generator/application.rb +45 -0
- data/lib/jeweler/generator/options.rb +64 -0
- data/lib/jeweler/tasks.rb +102 -0
- data/lib/jeweler/templates/.gitignore +5 -0
- data/lib/jeweler/templates/LICENSE +20 -0
- data/lib/jeweler/templates/README.rdoc +7 -0
- data/lib/jeweler/templates/Rakefile +116 -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 +11 -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 +9 -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 +83 -0
- data/test/fixtures/bar/VERSION.yml +4 -0
- data/test/geminstaller.yml +12 -0
- data/test/generators/initialization_test.rb +146 -0
- data/test/jeweler/commands/test_build_gem.rb +53 -0
- data/test/jeweler/commands/test_install_gem.rb +0 -0
- data/test/jeweler/commands/test_release.rb +150 -0
- data/test/jeweler/commands/test_release_to_rubyforge.rb +141 -0
- data/test/jeweler/commands/test_write_gemspec.rb +58 -0
- data/test/jeweler/commands/version/test_bump_major.rb +21 -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 +109 -0
- data/test/test_gemspec_helper.rb +36 -0
- data/test/test_generator.rb +179 -0
- data/test/test_helper.rb +51 -0
- data/test/test_jeweler.rb +136 -0
- data/test/test_options.rb +90 -0
- data/test/test_tasks.rb +40 -0
- data/test/test_version_helper.rb +115 -0
- metadata +152 -0
@@ -0,0 +1,141 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RubyForgeStub
|
4
|
+
attr_accessor :userconfig
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@userconfig = {}
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class Jeweler
|
12
|
+
module Commands
|
13
|
+
class TestReleaseToRubyforge < Test::Unit::TestCase
|
14
|
+
|
15
|
+
context "after running when rubyforge_project is defined" do
|
16
|
+
setup do
|
17
|
+
@rubyforge = RubyForgeStub.new
|
18
|
+
stub(@rubyforge).configure
|
19
|
+
stub(@rubyforge).login
|
20
|
+
stub(@rubyforge).add_release("MyRubyForgeProjectName", "zomg", "1.2.3", "pkg/zomg-1.2.3.gem")
|
21
|
+
|
22
|
+
@gempsec = Object.new
|
23
|
+
stub(@gemspec).description {"The zomg gem rocks."}
|
24
|
+
stub(@gemspec).rubyforge_project {"MyRubyForgeProjectName"}
|
25
|
+
stub(@gemspec).name {"zomg"}
|
26
|
+
|
27
|
+
@gemspec_helper = Object.new
|
28
|
+
stub(@gemspec_helper).write
|
29
|
+
stub(@gemspec_helper).gem_path {'pkg/zomg-1.2.3.gem'}
|
30
|
+
stub(@gemspec_helper).update_version('1.2.3')
|
31
|
+
|
32
|
+
@output = StringIO.new
|
33
|
+
|
34
|
+
@command = Jeweler::Commands::ReleaseToRubyforge.new
|
35
|
+
@command.output = @output
|
36
|
+
@command.repo = @repo
|
37
|
+
@command.gemspec = @gemspec
|
38
|
+
@command.gemspec_helper = @gemspec_helper
|
39
|
+
@command.version = '1.2.3'
|
40
|
+
@command.ruby_forge = @rubyforge
|
41
|
+
|
42
|
+
@command.run
|
43
|
+
end
|
44
|
+
|
45
|
+
should "configure" do
|
46
|
+
assert_received(@rubyforge) {|rubyforge| rubyforge.configure }
|
47
|
+
end
|
48
|
+
|
49
|
+
should "login" do
|
50
|
+
assert_received(@rubyforge) {|rubyforge| rubyforge.login }
|
51
|
+
end
|
52
|
+
|
53
|
+
should "set release notes" do
|
54
|
+
assert_equal "The zomg gem rocks.", @rubyforge.userconfig["release_notes"]
|
55
|
+
end
|
56
|
+
|
57
|
+
should "set preformatted to true" do
|
58
|
+
assert_equal true, @rubyforge.userconfig['preformatted']
|
59
|
+
end
|
60
|
+
|
61
|
+
should "add release" do
|
62
|
+
assert_received(@rubyforge) {|rubyforge| rubyforge.add_release("MyRubyForgeProjectName", "zomg", "1.2.3", "pkg/zomg-1.2.3.gem") }
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
context "after running when rubyforge_project is not defined in Jeweler::Tasks block in Rakefile" do
|
68
|
+
setup do
|
69
|
+
@rubyforge = RubyForgeStub.new
|
70
|
+
stub(@rubyforge).configure
|
71
|
+
stub(@rubyforge).login
|
72
|
+
stub(@rubyforge).add_release(nil, "zomg", "1.2.3", "pkg/zomg-1.2.3.gem")
|
73
|
+
|
74
|
+
@gempsec = Object.new
|
75
|
+
stub(@gemspec).description {"The zomg gem rocks."}
|
76
|
+
stub(@gemspec).rubyforge_project { nil }
|
77
|
+
stub(@gemspec).name {"zomg"}
|
78
|
+
|
79
|
+
@gemspec_helper = Object.new
|
80
|
+
stub(@gemspec_helper).write
|
81
|
+
stub(@gemspec_helper).gem_path {'pkg/zomg-1.2.3.gem'}
|
82
|
+
stub(@gemspec_helper).update_version('1.2.3')
|
83
|
+
|
84
|
+
@output = StringIO.new
|
85
|
+
|
86
|
+
@command = Jeweler::Commands::ReleaseToRubyforge.new
|
87
|
+
@command.output = @output
|
88
|
+
@command.repo = @repo
|
89
|
+
@command.gemspec = @gemspec
|
90
|
+
@command.gemspec_helper = @gemspec_helper
|
91
|
+
@command.version = '1.2.3'
|
92
|
+
@command.ruby_forge = @rubyforge
|
93
|
+
end
|
94
|
+
|
95
|
+
should "raise error" do
|
96
|
+
assert_raises RuntimeError, /not configured/i do
|
97
|
+
@command.run
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context "after running when rubyforge_project is not defined in ~/.rubyforge/auto_config.yml" do
|
103
|
+
setup do
|
104
|
+
@rubyforge = RubyForgeStub.new
|
105
|
+
stub(@rubyforge).configure
|
106
|
+
stub(@rubyforge).login
|
107
|
+
stub(@rubyforge).add_release("some_project_that_doesnt_exist", "zomg", "1.2.3", "pkg/zomg-1.2.3.gem") do
|
108
|
+
raise RuntimeError, "no <group_id> configured for <some_project_that_doesnt_exist>"
|
109
|
+
end
|
110
|
+
|
111
|
+
@gempsec = Object.new
|
112
|
+
stub(@gemspec).description {"The zomg gem rocks."}
|
113
|
+
stub(@gemspec).rubyforge_project { "some_project_that_doesnt_exist" }
|
114
|
+
stub(@gemspec).name {"zomg"}
|
115
|
+
|
116
|
+
@gemspec_helper = Object.new
|
117
|
+
stub(@gemspec_helper).write
|
118
|
+
stub(@gemspec_helper).gem_path {'pkg/zomg-1.2.3.gem'}
|
119
|
+
stub(@gemspec_helper).update_version('1.2.3')
|
120
|
+
|
121
|
+
@output = StringIO.new
|
122
|
+
|
123
|
+
@command = Jeweler::Commands::ReleaseToRubyforge.new
|
124
|
+
@command.output = @output
|
125
|
+
@command.repo = @repo
|
126
|
+
@command.gemspec = @gemspec
|
127
|
+
@command.gemspec_helper = @gemspec_helper
|
128
|
+
@command.version = '1.2.3'
|
129
|
+
@command.ruby_forge = @rubyforge
|
130
|
+
end
|
131
|
+
|
132
|
+
should "raise error" do
|
133
|
+
assert_raises RuntimeError, /no <group_id> configured/i do
|
134
|
+
@command.run
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
@@ -0,0 +1,58 @@
|
|
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
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,21 @@
|
|
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
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
@@ -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,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
|
@@ -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
|