namelessjon-jeweler 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +183 -0
- data/Rakefile +46 -0
- data/TODO +7 -0
- data/VERSION.yml +4 -0
- data/bin/jeweler +37 -0
- data/lib/jeweler.rb +34 -0
- data/lib/jeweler/bumping.rb +61 -0
- data/lib/jeweler/errors.rb +8 -0
- data/lib/jeweler/gemspec.rb +48 -0
- data/lib/jeweler/generator.rb +124 -0
- data/lib/jeweler/release.rb +28 -0
- data/lib/jeweler/tasks.rb +88 -0
- data/lib/jeweler/templates/.gitignore +3 -0
- data/lib/jeweler/templates/LICENSE +20 -0
- data/lib/jeweler/templates/README +9 -0
- data/lib/jeweler/templates/Rakefile +40 -0
- data/lib/jeweler/templates/spec/flunking_spec.rb +7 -0
- data/lib/jeweler/templates/spec/spec_helper.rb +5 -0
- data/lib/jeweler/templates/test/flunking_test.rb +7 -0
- data/lib/jeweler/templates/test/test_helper.rb +7 -0
- data/lib/jeweler/versioning.rb +50 -0
- data/test/fixtures/bar/VERSION.yml +4 -0
- data/test/jeweler_generator_test.rb +451 -0
- data/test/jeweler_test.rb +153 -0
- data/test/test_helper.rb +46 -0
- metadata +91 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
class Jeweler
|
2
|
+
module Release
|
3
|
+
|
4
|
+
def release
|
5
|
+
@repo.checkout('master')
|
6
|
+
|
7
|
+
raise "Hey buddy, try committing them files first" if any_pending_changes?
|
8
|
+
|
9
|
+
write_gemspec()
|
10
|
+
|
11
|
+
@repo.add(gemspec_path)
|
12
|
+
@repo.commit("Regenerated gemspec for version #{version}")
|
13
|
+
@repo.push
|
14
|
+
|
15
|
+
@repo.add_tag(release_tag)
|
16
|
+
@repo.push('origin', release_tag)
|
17
|
+
end
|
18
|
+
|
19
|
+
def release_tag
|
20
|
+
@release_tag ||= "v#{version}"
|
21
|
+
end
|
22
|
+
|
23
|
+
protected
|
24
|
+
def any_pending_changes?
|
25
|
+
@repo.status.added.empty? && @repo.status.deleted.empty? && @repo.status.changed.empty? && @repo.status.untracked.empty?
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/tasklib'
|
3
|
+
|
4
|
+
class Jeweler
|
5
|
+
class Tasks < ::Rake::TaskLib
|
6
|
+
def initialize(gemspec = nil, &block)
|
7
|
+
@gemspec = Gem::Specification.new()
|
8
|
+
block.call(@gemspec) if block
|
9
|
+
|
10
|
+
@jeweler = Jeweler.new(@gemspec)
|
11
|
+
|
12
|
+
define_tasks
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def ensure_version_yml(&block)
|
17
|
+
unless File.exists? 'VERSION.yml'
|
18
|
+
@jeweler.write_version(ENV['MAJOR'], ENV['MINOR'], ENV['PATCH'])
|
19
|
+
end
|
20
|
+
block.call if block
|
21
|
+
end
|
22
|
+
|
23
|
+
def define_tasks
|
24
|
+
desc "Generate and validates gemspec"
|
25
|
+
task :gemspec => ['gemspec:generate', 'gemspec:validate']
|
26
|
+
|
27
|
+
namespace :gemspec do
|
28
|
+
desc "Validates the gemspec"
|
29
|
+
task :validate do
|
30
|
+
@jeweler.validate_gemspec
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "Generates the gemspec"
|
34
|
+
task :generate do
|
35
|
+
ensure_version_yml do
|
36
|
+
@jeweler.write_gemspec
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "Displays the current version"
|
42
|
+
task :version => 'version:display'
|
43
|
+
|
44
|
+
namespace :version do
|
45
|
+
desc "Creates an initial version file. Respects the following environment variables, or defaults to 0: MAJOR, MINOR, PATCH"
|
46
|
+
task :write do
|
47
|
+
@jeweler.write_version(ENV['MAJOR'], ENV['MINOR'], ENV['PATCH'])
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "Displays the current version"
|
51
|
+
task :display do
|
52
|
+
ensure_version_yml do
|
53
|
+
puts "Current version: #{@jeweler.version}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
namespace :bump do
|
58
|
+
desc "Bump the gemspec by a major version."
|
59
|
+
task :major => 'version:display' do
|
60
|
+
ensure_version_yml do
|
61
|
+
@jeweler.bump_major_version
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "Bump the gemspec by a minor version."
|
66
|
+
task :minor => 'version:display' do
|
67
|
+
ensure_version_yml do
|
68
|
+
@jeweler.bump_minor_version
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
desc "Bump the gemspec by a patch version."
|
73
|
+
task :patch => 'version:display' do
|
74
|
+
ensure_version_yml do
|
75
|
+
@jeweler.bump_patch_version
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
desc "Release the current version. Includes updating the gemspec, pushing, and tagging the release"
|
82
|
+
task :release do
|
83
|
+
@jeweler.release
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 <%= user_name %>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
require 'rcov/rcovtask'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'jeweler'
|
8
|
+
Jeweler::Tasks.new do |s|
|
9
|
+
s.name = "<%= github_repo_name %>"
|
10
|
+
s.summary = "TODO"
|
11
|
+
s.email = "<%= user_email %>"
|
12
|
+
s.homepage = "<%= github_url %>"
|
13
|
+
s.description = "TODO"
|
14
|
+
s.authors = ["<%= user_name %>"]
|
15
|
+
end
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
18
|
+
end
|
19
|
+
|
20
|
+
Rake::TestTask.new do |t|
|
21
|
+
t.libs << 'lib'
|
22
|
+
t.pattern = '<%= testspec %>/**/*_<%= testspec %>.rb'
|
23
|
+
t.verbose = false
|
24
|
+
end
|
25
|
+
|
26
|
+
Rake::RDocTask.new do |rdoc|
|
27
|
+
rdoc.rdoc_dir = 'rdoc'
|
28
|
+
rdoc.title = '<%= github_repo_name %>'
|
29
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
30
|
+
rdoc.rdoc_files.include('README*')
|
31
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
32
|
+
end
|
33
|
+
|
34
|
+
Rcov::RcovTask.new do |t|
|
35
|
+
t.libs << "<%= testspec %>"
|
36
|
+
t.test_files = FileList['<%= testspec %>/**/*_<%= testspec %>.rb']
|
37
|
+
t.verbose = true
|
38
|
+
end
|
39
|
+
|
40
|
+
task :default => :rcov
|
@@ -0,0 +1,7 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class <%= constant_name %>Test < Test::Unit::TestCase
|
4
|
+
should "probably rename this file and start testing for real" do
|
5
|
+
flunk "hey buddy, you should probably rename this file and start testing for real"
|
6
|
+
end
|
7
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
class Jeweler
|
3
|
+
module Versioning
|
4
|
+
# Major version, as defined by the gemspec's Version module.
|
5
|
+
# For 1.5.3, this would return 1.
|
6
|
+
def major_version
|
7
|
+
version_yaml['major']
|
8
|
+
end
|
9
|
+
|
10
|
+
# Minor version, as defined by the gemspec's Version module.
|
11
|
+
# For 1.5.3, this would return 5.
|
12
|
+
def minor_version
|
13
|
+
version_yaml['minor']
|
14
|
+
end
|
15
|
+
|
16
|
+
# Patch version, as defined by the gemspec's Version module.
|
17
|
+
# For 1.5.3, this would return 5.
|
18
|
+
def patch_version
|
19
|
+
version_yaml['patch']
|
20
|
+
end
|
21
|
+
|
22
|
+
# Human readable version, which is used in the gemspec.
|
23
|
+
def version
|
24
|
+
"#{major_version}.#{minor_version}.#{patch_version}"
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
def version_yaml_path
|
29
|
+
denormalized_path = File.join(@base_dir, 'VERSION.yml')
|
30
|
+
absolute_path = File.expand_path(denormalized_path)
|
31
|
+
absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
|
32
|
+
end
|
33
|
+
|
34
|
+
def version_yaml
|
35
|
+
@version_yaml ||= read_version_yaml
|
36
|
+
end
|
37
|
+
|
38
|
+
def read_version_yaml
|
39
|
+
if File.exists?(version_yaml_path)
|
40
|
+
YAML.load_file(version_yaml_path)
|
41
|
+
else
|
42
|
+
raise VersionYmlError, "#{version_yaml_path} does not exist!"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def refresh_version
|
47
|
+
@version_yaml = read_version_yaml
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,451 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class JewelerTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def self.should_create_directory(directory)
|
6
|
+
should "create #{directory} directory" do
|
7
|
+
assert File.exists?(File.join(@tmp_dir, directory))
|
8
|
+
assert File.directory?(File.join(@tmp_dir, directory))
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.should_create_file(file)
|
13
|
+
should "create file #{file}" do
|
14
|
+
assert File.exists?(File.join(@tmp_dir, file))
|
15
|
+
assert File.file?(File.join(@tmp_dir, file))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.should_be_checked_in(file)
|
20
|
+
should "have #{file} checked in" do
|
21
|
+
status = @repo.status[file]
|
22
|
+
assert_not_nil status, "wasn't able to get status for #{file}"
|
23
|
+
assert ! status.untracked, "#{file} was untracked"
|
24
|
+
assert_nil status.type, "#{file} had a type. it should have been nil"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "given a nil github repo name" do
|
29
|
+
setup do
|
30
|
+
@block = lambda { Jeweler::Generator.new(nil, nil) }
|
31
|
+
end
|
32
|
+
|
33
|
+
should "raise an error" do
|
34
|
+
assert_raise Jeweler::NoGitHubRepoNameGiven do
|
35
|
+
@block.call
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "without git user's name set" do
|
41
|
+
setup do
|
42
|
+
Jeweler::Generator.any_instance.stubs(:read_git_config).returns({'user.email' => 'bar@example.com'})
|
43
|
+
end
|
44
|
+
|
45
|
+
context "instantiating new generator" do
|
46
|
+
setup do
|
47
|
+
@block = lambda { Jeweler::Generator.new('the-perfect-gem')}
|
48
|
+
end
|
49
|
+
|
50
|
+
should "raise no git user name exception" do
|
51
|
+
assert_raise Jeweler::NoGitUserName do
|
52
|
+
@block.call
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "without git user's email set" do
|
59
|
+
setup do
|
60
|
+
Jeweler::Generator.any_instance.stubs(:read_git_config).returns({'user.name' => 'foo'})
|
61
|
+
end
|
62
|
+
|
63
|
+
context "instantiating new generator" do
|
64
|
+
setup do
|
65
|
+
@block = lambda { Jeweler::Generator.new('the-perfect-gem')}
|
66
|
+
end
|
67
|
+
|
68
|
+
should "raise no git user name exception" do
|
69
|
+
assert_raise Jeweler::NoGitUserEmail do
|
70
|
+
@block.call
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context "without github username set" do
|
77
|
+
setup do
|
78
|
+
Jeweler::Generator.any_instance.stubs(:read_git_config).
|
79
|
+
returns({'user.email' => 'bar@example.com', 'user.name' => 'foo'})
|
80
|
+
end
|
81
|
+
|
82
|
+
context "instantiating new generator" do
|
83
|
+
setup do
|
84
|
+
@block = lambda { Jeweler::Generator.new('the-perfect-gem')}
|
85
|
+
end
|
86
|
+
|
87
|
+
should "raise no github user exception" do
|
88
|
+
assert_raise Jeweler::NoGitHubUser do
|
89
|
+
@block.call
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context "with valid git user configuration" do
|
96
|
+
setup do
|
97
|
+
Jeweler::Generator.any_instance.stubs(:read_git_config).
|
98
|
+
returns({'user.name' => 'foo', 'user.email' => 'bar@example.com', 'github.user' => 'technicalpickles'})
|
99
|
+
end
|
100
|
+
|
101
|
+
context "for technicalpickle's the-perfect-gem repository" do
|
102
|
+
setup do
|
103
|
+
@generator = Jeweler::Generator.new('the-perfect-gem')
|
104
|
+
end
|
105
|
+
|
106
|
+
should "assign 'foo' to user's name" do
|
107
|
+
assert_equal 'foo', @generator.user_name
|
108
|
+
end
|
109
|
+
|
110
|
+
should "assign 'bar@example.com to user's email" do
|
111
|
+
assert_equal 'bar@example.com', @generator.user_email
|
112
|
+
end
|
113
|
+
|
114
|
+
should "assign github remote" do
|
115
|
+
assert_equal 'git@github.com:technicalpickles/the-perfect-gem.git', @generator.github_remote
|
116
|
+
end
|
117
|
+
|
118
|
+
should "determine github username as technicalpickles" do
|
119
|
+
assert_equal 'technicalpickles', @generator.github_username
|
120
|
+
end
|
121
|
+
|
122
|
+
should "determine github repository name as the-perfect-gem" do
|
123
|
+
assert_equal 'the-perfect-gem', @generator.github_repo_name
|
124
|
+
end
|
125
|
+
|
126
|
+
should "determine github url as http://github.com/technicalpickles/the-perfect-gem" do
|
127
|
+
assert_equal 'http://github.com/technicalpickles/the-perfect-gem', @generator.github_url
|
128
|
+
end
|
129
|
+
|
130
|
+
should "determine target directory as the same as the github repository name" do
|
131
|
+
assert_equal @generator.github_repo_name, @generator.target_dir
|
132
|
+
end
|
133
|
+
|
134
|
+
should "determine lib directory as being inside the target directory" do
|
135
|
+
assert_equal File.join(@generator.target_dir, 'lib'), @generator.lib_dir
|
136
|
+
end
|
137
|
+
|
138
|
+
should "determine test directory as being inside the target directory" do
|
139
|
+
assert_equal File.join(@generator.target_dir, 'test'), @generator.test_dir
|
140
|
+
end
|
141
|
+
|
142
|
+
should "determine constant name as ThePerfectGem" do
|
143
|
+
assert_equal 'ThePerfectGem', @generator.constant_name
|
144
|
+
end
|
145
|
+
|
146
|
+
should "determine file name prefix as the_perfect_gem" do
|
147
|
+
assert_equal 'the_perfect_gem', @generator.file_name_prefix
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
|
152
|
+
context "and cleaned out tmp directory" do
|
153
|
+
setup do
|
154
|
+
@tmp_dir = File.join(File.dirname(__FILE__), 'tmp')
|
155
|
+
FileUtils.rm_rf(@tmp_dir)
|
156
|
+
|
157
|
+
assert ! File.exists?(@tmp_dir)
|
158
|
+
end
|
159
|
+
|
160
|
+
teardown do
|
161
|
+
FileUtils.rm_rf(@tmp_dir)
|
162
|
+
end
|
163
|
+
|
164
|
+
context "for technicalpickles's the-perfect-gem repo and working directory 'tmp'" do
|
165
|
+
setup do
|
166
|
+
@generator = Jeweler::Generator.new('the-perfect-gem', @tmp_dir)
|
167
|
+
end
|
168
|
+
|
169
|
+
should "use tmp for target directory" do
|
170
|
+
assert_equal @tmp_dir, @generator.target_dir
|
171
|
+
end
|
172
|
+
|
173
|
+
context "running for spec = false" do
|
174
|
+
setup do
|
175
|
+
@generator.run
|
176
|
+
end
|
177
|
+
|
178
|
+
should 'create target directory' do
|
179
|
+
assert File.exists?(@tmp_dir)
|
180
|
+
end
|
181
|
+
|
182
|
+
should_create_directory 'lib'
|
183
|
+
should_create_directory 'test'
|
184
|
+
|
185
|
+
should_create_file 'LICENSE'
|
186
|
+
should_create_file 'README'
|
187
|
+
should_create_file 'lib/the_perfect_gem.rb'
|
188
|
+
should_create_file 'test/test_helper.rb'
|
189
|
+
should_create_file 'test/the_perfect_gem_test.rb'
|
190
|
+
should_create_file '.gitignore'
|
191
|
+
|
192
|
+
context "LICENSE" do
|
193
|
+
setup do
|
194
|
+
@content = File.read((File.join(@tmp_dir, 'LICENSE')))
|
195
|
+
end
|
196
|
+
|
197
|
+
should "include copyright for this year with user's name" do
|
198
|
+
assert_match 'Copyright (c) 2008 foo', @content
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
context "Rakefile" do
|
203
|
+
setup do
|
204
|
+
@content = File.read((File.join(@tmp_dir, 'Rakefile')))
|
205
|
+
end
|
206
|
+
|
207
|
+
should "include repo's name as the gem's name" do
|
208
|
+
assert_match 's.name = "the-perfect-gem"', @content
|
209
|
+
end
|
210
|
+
|
211
|
+
should "include the user's email as the gem's email" do
|
212
|
+
assert_match 's.email = "bar@example.com"', @content
|
213
|
+
end
|
214
|
+
|
215
|
+
should "include the github repo's url as the gem's url" do
|
216
|
+
assert_match 's.homepage = "http://github.com/technicalpickles/the-perfect-gem"', @content
|
217
|
+
end
|
218
|
+
|
219
|
+
should "include a glob to match test files in the TestTask" do
|
220
|
+
assert_match "t.pattern = 'test/**/*_test.rb'", @content
|
221
|
+
end
|
222
|
+
|
223
|
+
should "include a glob to match test files in the RcovTask" do
|
224
|
+
assert_match "t.test_files = FileList['test/**/*_test.rb']", @content
|
225
|
+
end
|
226
|
+
|
227
|
+
should "push test dir into RcovTask libs" do
|
228
|
+
assert_match 't.libs << "test"', @content
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
context ".gitignore" do
|
233
|
+
setup do
|
234
|
+
@content = File.read((File.join(@tmp_dir, '.gitignore')))
|
235
|
+
end
|
236
|
+
|
237
|
+
should "include vim swap files" do
|
238
|
+
assert_match '*.sw?', @content
|
239
|
+
end
|
240
|
+
|
241
|
+
should "include coverage" do
|
242
|
+
assert_match 'coverage', @content
|
243
|
+
end
|
244
|
+
|
245
|
+
should "include .DS_Store" do
|
246
|
+
assert_match '.DS_Store', @content
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
|
251
|
+
context "test/the_perfect_gem_test.rb" do
|
252
|
+
setup do
|
253
|
+
@content = File.read((File.join(@tmp_dir, 'test', 'the_perfect_gem_test.rb')))
|
254
|
+
end
|
255
|
+
|
256
|
+
should "have class of ThePerfectGemTest" do
|
257
|
+
assert_match 'class ThePerfectGemTest < Test::Unit::TestCase', @content
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
|
262
|
+
context "created git repo" do
|
263
|
+
setup do
|
264
|
+
@repo = Git.open(@tmp_dir)
|
265
|
+
end
|
266
|
+
|
267
|
+
should 'have one commit log' do
|
268
|
+
assert_equal 1, @repo.log.size
|
269
|
+
end
|
270
|
+
|
271
|
+
should "have one commit log an initial commit message" do
|
272
|
+
# TODO message seems to include leading whitespace, could probably fix that in ruby-git
|
273
|
+
assert_match 'Initial commit to the-perfect-gem.', @repo.log.first.message
|
274
|
+
end
|
275
|
+
|
276
|
+
should_be_checked_in 'README'
|
277
|
+
should_be_checked_in 'Rakefile'
|
278
|
+
should_be_checked_in 'LICENSE'
|
279
|
+
should_be_checked_in 'lib/the_perfect_gem.rb'
|
280
|
+
should_be_checked_in 'test/test_helper.rb'
|
281
|
+
should_be_checked_in 'test/the_perfect_gem_test.rb'
|
282
|
+
should_be_checked_in '.gitignore'
|
283
|
+
|
284
|
+
should "have no untracked files" do
|
285
|
+
assert_equal 0, @repo.status.untracked.size
|
286
|
+
end
|
287
|
+
|
288
|
+
should "have no changed files" do
|
289
|
+
assert_equal 0, @repo.status.changed.size
|
290
|
+
end
|
291
|
+
|
292
|
+
should "have no added files" do
|
293
|
+
assert_equal 0, @repo.status.added.size
|
294
|
+
end
|
295
|
+
|
296
|
+
should "have no deleted files" do
|
297
|
+
assert_equal 0, @repo.status.deleted.size
|
298
|
+
end
|
299
|
+
|
300
|
+
|
301
|
+
should "have git@github.com:technicalpickles/the-perfect-gem.git as origin remote" do
|
302
|
+
assert_equal 1, @repo.remotes.size
|
303
|
+
remote = @repo.remotes.first
|
304
|
+
assert_equal 'origin', remote.name
|
305
|
+
assert_equal 'git@github.com:technicalpickles/the-perfect-gem.git', remote.url
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
context "running for spec = true" do
|
311
|
+
setup do
|
312
|
+
@generator.spec = true
|
313
|
+
@generator.run
|
314
|
+
end
|
315
|
+
|
316
|
+
should 'create target directory' do
|
317
|
+
assert File.exists?(@tmp_dir)
|
318
|
+
end
|
319
|
+
|
320
|
+
should_create_directory 'lib'
|
321
|
+
should_create_directory 'spec'
|
322
|
+
|
323
|
+
should_create_file 'LICENSE'
|
324
|
+
should_create_file 'README'
|
325
|
+
should_create_file 'lib/the_perfect_gem.rb'
|
326
|
+
should_create_file 'spec/spec_helper.rb'
|
327
|
+
should_create_file 'spec/the_perfect_gem_spec.rb'
|
328
|
+
should_create_file '.gitignore'
|
329
|
+
|
330
|
+
context "LICENSE" do
|
331
|
+
setup do
|
332
|
+
@content = File.read((File.join(@tmp_dir, 'LICENSE')))
|
333
|
+
end
|
334
|
+
|
335
|
+
should "include copyright for this year with user's name" do
|
336
|
+
assert_match 'Copyright (c) 2008 foo', @content
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
context "Rakefile" do
|
341
|
+
setup do
|
342
|
+
@content = File.read((File.join(@tmp_dir, 'Rakefile')))
|
343
|
+
end
|
344
|
+
|
345
|
+
should "include repo's name as the gem's name" do
|
346
|
+
assert_match 's.name = "the-perfect-gem"', @content
|
347
|
+
end
|
348
|
+
|
349
|
+
should "include the user's email as the gem's email" do
|
350
|
+
assert_match 's.email = "bar@example.com"', @content
|
351
|
+
end
|
352
|
+
|
353
|
+
should "include the github repo's url as the gem's url" do
|
354
|
+
assert_match 's.homepage = "http://github.com/technicalpickles/the-perfect-gem"', @content
|
355
|
+
end
|
356
|
+
|
357
|
+
should "include a glob to match spec files in the TestTask" do
|
358
|
+
assert_match "t.pattern = 'spec/**/*_spec.rb'", @content
|
359
|
+
end
|
360
|
+
|
361
|
+
should "include a glob to match spec files in the RcovTask" do
|
362
|
+
assert_match "t.test_files = FileList['spec/**/*_spec.rb']", @content
|
363
|
+
end
|
364
|
+
|
365
|
+
should "push spec dir into RcovTask libs" do
|
366
|
+
assert_match 't.libs << "spec"', @content
|
367
|
+
end
|
368
|
+
end
|
369
|
+
|
370
|
+
context ".gitignore" do
|
371
|
+
setup do
|
372
|
+
@content = File.read((File.join(@tmp_dir, '.gitignore')))
|
373
|
+
end
|
374
|
+
|
375
|
+
should "include vim swap files" do
|
376
|
+
assert_match '*.sw?', @content
|
377
|
+
end
|
378
|
+
|
379
|
+
should "include coverage" do
|
380
|
+
assert_match 'coverage', @content
|
381
|
+
end
|
382
|
+
|
383
|
+
should "include .DS_Store" do
|
384
|
+
assert_match '.DS_Store', @content
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
|
389
|
+
context "spec/the_perfect_gem_spec.rb" do
|
390
|
+
setup do
|
391
|
+
@content = File.read((File.join(@tmp_dir, 'spec', 'the_perfect_gem_spec.rb')))
|
392
|
+
end
|
393
|
+
|
394
|
+
should "describe ThePerfectGem" do
|
395
|
+
assert_match 'describe "ThePerfectGem" do', @content
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
399
|
+
|
400
|
+
context "created git repo" do
|
401
|
+
setup do
|
402
|
+
@repo = Git.open(@tmp_dir)
|
403
|
+
end
|
404
|
+
|
405
|
+
should 'have one commit log' do
|
406
|
+
assert_equal 1, @repo.log.size
|
407
|
+
end
|
408
|
+
|
409
|
+
should "have one commit log an initial commit message" do
|
410
|
+
# TODO message seems to include leading whitespace, could probably fix that in ruby-git
|
411
|
+
assert_match 'Initial commit to the-perfect-gem.', @repo.log.first.message
|
412
|
+
end
|
413
|
+
|
414
|
+
should_be_checked_in 'README'
|
415
|
+
should_be_checked_in 'Rakefile'
|
416
|
+
should_be_checked_in 'LICENSE'
|
417
|
+
should_be_checked_in 'lib/the_perfect_gem.rb'
|
418
|
+
should_be_checked_in 'spec/spec_helper.rb'
|
419
|
+
should_be_checked_in 'spec/the_perfect_gem_spec.rb'
|
420
|
+
should_be_checked_in '.gitignore'
|
421
|
+
|
422
|
+
should "have no untracked files" do
|
423
|
+
assert_equal 0, @repo.status.untracked.size
|
424
|
+
end
|
425
|
+
|
426
|
+
should "have no changed files" do
|
427
|
+
assert_equal 0, @repo.status.changed.size
|
428
|
+
end
|
429
|
+
|
430
|
+
should "have no added files" do
|
431
|
+
assert_equal 0, @repo.status.added.size
|
432
|
+
end
|
433
|
+
|
434
|
+
should "have no deleted files" do
|
435
|
+
assert_equal 0, @repo.status.deleted.size
|
436
|
+
end
|
437
|
+
|
438
|
+
|
439
|
+
should "have git@github.com:technicalpickles/the-perfect-gem.git as origin remote" do
|
440
|
+
assert_equal 1, @repo.remotes.size
|
441
|
+
remote = @repo.remotes.first
|
442
|
+
assert_equal 'origin', remote.name
|
443
|
+
assert_equal 'git@github.com:technicalpickles/the-perfect-gem.git', remote.url
|
444
|
+
end
|
445
|
+
end
|
446
|
+
end
|
447
|
+
end
|
448
|
+
end
|
449
|
+
end
|
450
|
+
|
451
|
+
end
|