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,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
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'shoulda'
|
5
|
+
require 'ruby-debug'
|
6
|
+
require 'rr'
|
7
|
+
require 'output_catcher'
|
8
|
+
require 'time'
|
9
|
+
|
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'
|
15
|
+
|
16
|
+
# Use vendored gem because of limited gem availability on runcoderun
|
17
|
+
# This is loosely based on 'vendor everything'.
|
18
|
+
Dir[File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', '**')].each do |dir|
|
19
|
+
lib = "#{dir}/lib"
|
20
|
+
$LOAD_PATH.unshift(lib) if File.directory?(lib)
|
21
|
+
end
|
22
|
+
|
23
|
+
class Test::Unit::TestCase
|
24
|
+
include RR::Adapters::TestUnit unless include?(RR::Adapters::TestUnit)
|
25
|
+
|
26
|
+
def catch_out(&block)
|
27
|
+
OutputCatcher.catch_out do
|
28
|
+
block.call
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def fixture_dir
|
33
|
+
File.join(File.dirname(__FILE__), 'fixtures', 'bar')
|
34
|
+
end
|
35
|
+
|
36
|
+
def tmp_dir
|
37
|
+
File.join(File.dirname(__FILE__), 'tmp')
|
38
|
+
end
|
39
|
+
|
40
|
+
def build_spec(*files)
|
41
|
+
Gem::Specification.new do |s|
|
42
|
+
s.name = "bar"
|
43
|
+
s.summary = "Simple and opinionated helper for creating Rubygem projects on GitHub"
|
44
|
+
s.email = "josh@technicalpickles.com"
|
45
|
+
s.homepage = "http://github.com/technicalpickles/jeweler"
|
46
|
+
s.description = "Simple and opinionated helper for creating Rubygem projects on GitHub"
|
47
|
+
s.authors = ["Josh Nichols"]
|
48
|
+
s.files = FileList[*files] unless files.empty?
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestJeweler < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@now = Time.now
|
7
|
+
stub(Time).now { @now }
|
8
|
+
|
9
|
+
FileUtils.rm_rf("#{File.dirname(__FILE__)}/tmp")
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown
|
13
|
+
FileUtils.rm_rf("#{File.dirname(__FILE__)}/tmp")
|
14
|
+
end
|
15
|
+
|
16
|
+
context "Initializing jewewler in a blank directory" do
|
17
|
+
setup do
|
18
|
+
FileUtils.mkdir_p(tmp_dir)
|
19
|
+
@jeweler = Jeweler.new(build_spec, tmp_dir)
|
20
|
+
end
|
21
|
+
|
22
|
+
should "not create a VERSION.yml" do
|
23
|
+
assert ! File.exists?(File.join(tmp_dir, 'VERSION.yml'))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
context "A Jeweler with a VERSION.yml" do
|
29
|
+
setup do
|
30
|
+
FileUtils.cp_r(fixture_dir, tmp_dir)
|
31
|
+
|
32
|
+
@jeweler = Jeweler.new(build_spec, tmp_dir)
|
33
|
+
@jeweler.output = StringIO.new
|
34
|
+
end
|
35
|
+
|
36
|
+
should_have_major_version 1
|
37
|
+
should_have_minor_version 5
|
38
|
+
should_have_patch_version 2
|
39
|
+
should_be_version '1.5.2'
|
40
|
+
|
41
|
+
context "bumping the patch version" do
|
42
|
+
setup do
|
43
|
+
@jeweler.bump_patch_version
|
44
|
+
end
|
45
|
+
should_bump_version 1, 5, 3
|
46
|
+
end
|
47
|
+
|
48
|
+
context "bumping the minor version" do
|
49
|
+
setup do
|
50
|
+
@jeweler.bump_minor_version
|
51
|
+
end
|
52
|
+
|
53
|
+
should_bump_version 1, 6, 0
|
54
|
+
end
|
55
|
+
|
56
|
+
context "bumping the major version" do
|
57
|
+
setup do
|
58
|
+
@jeweler.bump_major_version
|
59
|
+
end
|
60
|
+
|
61
|
+
should_bump_version 2, 0, 0
|
62
|
+
end
|
63
|
+
|
64
|
+
should "should populate gemspec's files" do
|
65
|
+
assert ! @jeweler.gemspec.files.empty?
|
66
|
+
end
|
67
|
+
|
68
|
+
context "with standard 'files' specified" do
|
69
|
+
setup do
|
70
|
+
@alt_jeweler = Jeweler.new(build_spec("[A-Z]*.*", "{bin,generators,lib,test,spec}/**/*"), tmp_dir)
|
71
|
+
end
|
72
|
+
|
73
|
+
should "have the same files as when no 'files' are specified" do
|
74
|
+
assert_equal @jeweler.gemspec.files, @alt_jeweler.gemspec.files
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context "gemsepc's rdoc" do
|
79
|
+
should 'have be enabled' do
|
80
|
+
assert @jeweler.gemspec.has_rdoc
|
81
|
+
end
|
82
|
+
|
83
|
+
should 'do inline source' do
|
84
|
+
assert @jeweler.gemspec.rdoc_options.include?('--inline-source')
|
85
|
+
end
|
86
|
+
|
87
|
+
should 'be utf-8' do
|
88
|
+
assert @jeweler.gemspec.rdoc_options.include?('--charset=UTF-8')
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
context "writing the gemspec" do
|
94
|
+
setup do
|
95
|
+
@jeweler.write_gemspec
|
96
|
+
@output = @jeweler.output.string
|
97
|
+
end
|
98
|
+
|
99
|
+
should "create bar.gemspec" do
|
100
|
+
assert File.exists?(File.join(tmp_dir, 'bar.gemspec'))
|
101
|
+
end
|
102
|
+
|
103
|
+
should "have created a valid gemspec" do
|
104
|
+
assert @jeweler.valid_gemspec?
|
105
|
+
end
|
106
|
+
|
107
|
+
should "output the name of the gemspec" do
|
108
|
+
assert_match 'bar.gemspec', @output
|
109
|
+
end
|
110
|
+
|
111
|
+
context "re-reading the gemspec" do
|
112
|
+
setup do
|
113
|
+
gemspec_path = File.join(tmp_dir, 'bar.gemspec')
|
114
|
+
data = File.read(gemspec_path)
|
115
|
+
|
116
|
+
@parsed_spec = eval("$SAFE = 3\n#{data}", binding, gemspec_path)
|
117
|
+
end
|
118
|
+
|
119
|
+
should "have version 1.5.2" do
|
120
|
+
assert_equal '1.5.2', @parsed_spec.version.version
|
121
|
+
end
|
122
|
+
|
123
|
+
should "have date filled in" do
|
124
|
+
assert_equal Time.local(@now.year, @now.month, @now.day), @parsed_spec.date
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
should "raise an exception when created with a nil gemspec" do
|
131
|
+
assert_raises Jeweler::GemspecError do
|
132
|
+
@jeweler = Jeweler.new(nil, tmp_dir)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
@@ -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
|