technicalpickles-jeweler 0.4.1 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +12 -12
- data/Rakefile +1 -1
- data/VERSION.yml +1 -1
- data/bin/jeweler +37 -6
- data/lib/jeweler/bumping.rb +2 -2
- data/lib/jeweler/errors.rb +1 -1
- data/lib/jeweler/gemspec.rb +5 -5
- data/lib/jeweler/generator.rb +72 -35
- data/lib/jeweler/release.rb +7 -7
- data/lib/jeweler/tasks.rb +7 -7
- data/lib/jeweler/templates/Rakefile +4 -4
- data/lib/jeweler/templates/spec/flunking_spec.rb +7 -0
- data/lib/jeweler/templates/spec/spec_helper.rb +5 -0
- data/lib/jeweler/versioning.rb +4 -4
- data/lib/jeweler.rb +4 -4
- data/test/jeweler_generator_test.rb +222 -64
- data/test/jeweler_test.rb +20 -57
- data/test/shoulda_macros/jeweler_macros.rb +38 -0
- data/test/test_helper.rb +10 -6
- metadata +7 -2
data/README.markdown
CHANGED
@@ -11,7 +11,7 @@ Trouble is when developing your Rubygems on GitHub, you generally do one of the
|
|
11
11
|
* Use hoe or echoe for generating the gemspec
|
12
12
|
* ... why use utilities made for the days before GitHub existed?
|
13
13
|
* ... why have extra stuff you aren't going to use?
|
14
|
-
|
14
|
+
|
15
15
|
Jeweler was created with a few goals in mind:
|
16
16
|
|
17
17
|
* Only use a Gem::Specification as configuration
|
@@ -48,7 +48,7 @@ Armed with the gem, we can begin diving into an example. [the-perfect-gem](http:
|
|
48
48
|
rescue LoadError
|
49
49
|
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
Here's a rundown of what's happening:
|
53
53
|
|
54
54
|
* Wrap everything in a begin block, and rescue from LoadError
|
@@ -72,18 +72,18 @@ Here's a rundown of what's happening:
|
|
72
72
|
* `executables`, if you have any scripts
|
73
73
|
* `add_dependency`, if you have any dependencies
|
74
74
|
* Keep in mind that this is a `Gem::Specification`, so you can do whatever you would need to do to get your gem in shape
|
75
|
-
|
75
|
+
|
76
76
|
## Bootstrap a new project
|
77
77
|
|
78
78
|
Before proceeding, take a minute to setup your git environment, specifically your name and email address:
|
79
79
|
|
80
80
|
$ git config --global user.email johndoe@example.com
|
81
81
|
$ git config --global user.name 'John Doe'
|
82
|
-
|
82
|
+
|
83
83
|
Jeweler provides a generator of sorts, `jeweler`. It takes two arguments: your GitHub username and a repository name.
|
84
84
|
|
85
85
|
$ jeweler technicalpickles the-perfect-gem
|
86
|
-
|
86
|
+
|
87
87
|
Basically, this does:
|
88
88
|
|
89
89
|
* Creates the the-perfect-gem directory
|
@@ -98,13 +98,13 @@ Basically, this does:
|
|
98
98
|
* Makes it a git repo
|
99
99
|
* Sets up `git@github.com:technicalpickles/jeweler.git` as the `origin` git remote
|
100
100
|
* Makes an initial commit, but does not push
|
101
|
-
|
101
|
+
|
102
102
|
At this point, you probably should create a repository by wandering to [http://github.com/repositories/new](http://github.com/repositories/new). Be sure to use the same project name you told Jeweler.
|
103
103
|
|
104
104
|
With the repository firmly created, just push it:
|
105
105
|
|
106
106
|
$ git push origin master
|
107
|
-
|
107
|
+
|
108
108
|
You also probably should [enable RubyGem creation for you repository](http://github.com/blog/51-github-s-rubygem-server): Go to your project's edit page and check the 'RubyGem' box.
|
109
109
|
|
110
110
|
## Overview of Jeweler workflow
|
@@ -115,7 +115,7 @@ Here's the general idea:
|
|
115
115
|
* Version bump
|
116
116
|
* Release
|
117
117
|
* Have a delicious scotch
|
118
|
-
|
118
|
+
|
119
119
|
The hacking and the scotch are up to you, but Jeweler provides rake tasks for the rest.
|
120
120
|
|
121
121
|
### Versioning
|
@@ -125,9 +125,9 @@ Versioning information is stored in `VERSION.yml`. It's a plain ol' YAML file wh
|
|
125
125
|
* major
|
126
126
|
* minor
|
127
127
|
* patch
|
128
|
-
|
128
|
+
|
129
129
|
Consider, for a second, `1.5.3`.
|
130
|
-
|
130
|
+
|
131
131
|
* major = 1
|
132
132
|
* minor = 5
|
133
133
|
* patch = 3
|
@@ -161,7 +161,7 @@ The process of version bumping does a commit to your repo, so make sure your rep
|
|
161
161
|
It's pretty straight forward:
|
162
162
|
|
163
163
|
$ rake release
|
164
|
-
|
164
|
+
|
165
165
|
This takes care of:
|
166
166
|
|
167
167
|
* Generating a `.gemspec` for you project, with the version you just bumped to
|
@@ -179,5 +179,5 @@ If it happens to be down, you can also check out the GitHub Gem repo's [list](ht
|
|
179
179
|
|
180
180
|
<hack, hack, hack, commit>
|
181
181
|
$ rake version:bump:patch release
|
182
|
-
|
182
|
+
|
183
183
|
Now browse to http://gems.github.com/yourname/yourproject, and wait for it to be built.
|
data/Rakefile
CHANGED
data/VERSION.yml
CHANGED
data/bin/jeweler
CHANGED
@@ -1,15 +1,46 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'rubygems'
|
3
|
+
require 'optparse'
|
3
4
|
|
4
5
|
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
5
6
|
require 'jeweler'
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
class JewelerOpts < Hash
|
9
|
+
attr_reader :opts
|
10
|
+
|
11
|
+
def initialize(args)
|
12
|
+
super()
|
13
|
+
|
14
|
+
self[:test_style] = :shoulda
|
15
|
+
|
16
|
+
@opts = OptionParser.new do |o|
|
17
|
+
o.banner = "Usage: #{File.basename($0)} [options] reponame\ne.g. #{File.basename($0)} the-perfect-gem"
|
18
|
+
|
19
|
+
o.on('--bacon', 'generate bacon specs') do
|
20
|
+
self[:test_style] = :bacon
|
21
|
+
end
|
22
|
+
|
23
|
+
o.on('--shoulda', 'generate shoulda tests') do
|
24
|
+
self[:test_style] = :shoulda
|
25
|
+
end
|
26
|
+
|
27
|
+
o.on_tail('-h', '--help', 'display this help and exit') do
|
28
|
+
puts o
|
29
|
+
exit
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
@opts.parse!(args)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
options = JewelerOpts.new(ARGV)
|
38
|
+
|
39
|
+
unless ARGV.size == 1
|
40
|
+
puts options.opts
|
9
41
|
exit 1
|
10
42
|
end
|
11
43
|
|
12
|
-
|
13
|
-
|
14
|
-
generator
|
15
|
-
generator.run
|
44
|
+
github_repo_name = ARGV.first
|
45
|
+
generator = Jeweler::Generator.new github_repo_name, options
|
46
|
+
generator.run
|
data/lib/jeweler/bumping.rb
CHANGED
@@ -32,7 +32,7 @@ class Jeweler
|
|
32
32
|
major ||= 0
|
33
33
|
minor ||= 0
|
34
34
|
patch ||= 0
|
35
|
-
|
35
|
+
|
36
36
|
File.open(version_yaml_path, 'w+') do |f|
|
37
37
|
version_hash = {
|
38
38
|
'major' => major.to_i,
|
@@ -43,7 +43,7 @@ class Jeweler
|
|
43
43
|
end
|
44
44
|
|
45
45
|
refresh_version
|
46
|
-
|
46
|
+
|
47
47
|
@gemspec.version = version
|
48
48
|
|
49
49
|
puts "Wrote to #{version_yaml_path}: #{version}"
|
data/lib/jeweler/errors.rb
CHANGED
data/lib/jeweler/gemspec.rb
CHANGED
@@ -10,7 +10,7 @@ class Jeweler
|
|
10
10
|
end
|
11
11
|
puts "Generated: #{gemspec_path}"
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
# Validates the gemspec in an environment similar to how GitHub would build
|
15
15
|
# it. See http://gist.github.com/16215
|
16
16
|
def validate_gemspec
|
@@ -22,8 +22,8 @@ class Jeweler
|
|
22
22
|
raise
|
23
23
|
end
|
24
24
|
end
|
25
|
-
|
26
|
-
|
25
|
+
|
26
|
+
|
27
27
|
def valid_gemspec?
|
28
28
|
begin
|
29
29
|
parse_gemspec
|
@@ -32,12 +32,12 @@ class Jeweler
|
|
32
32
|
false
|
33
33
|
end
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
def parse_gemspec(data = nil)
|
37
37
|
data ||= File.read(gemspec_path)
|
38
38
|
Thread.new { eval("$SAFE = 3\n#{data}", binding, gemspec_path) }.join
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
protected
|
42
42
|
def gemspec_path
|
43
43
|
denormalized_path = File.join(@base_dir, "#{@gemspec.name}.gemspec")
|
data/lib/jeweler/generator.rb
CHANGED
@@ -10,33 +10,31 @@ class Jeweler
|
|
10
10
|
end
|
11
11
|
class NoGitHubRepoNameGiven < StandardError
|
12
12
|
end
|
13
|
-
class
|
13
|
+
class NoGitHubUser < StandardError
|
14
|
+
end
|
15
|
+
class GitInitFailed < StandardError
|
14
16
|
end
|
15
17
|
|
18
|
+
|
16
19
|
class Generator
|
17
20
|
attr_accessor :target_dir, :user_name, :user_email,
|
18
21
|
:github_repo_name, :github_remote, :github_url, :github_username,
|
19
|
-
:lib_dir, :
|
22
|
+
:lib_dir, :constant_name, :file_name_prefix, :config, :test_style
|
20
23
|
|
21
|
-
def initialize(
|
22
|
-
|
23
|
-
raise NoGitHubUsernameGiven
|
24
|
-
end
|
25
|
-
self.github_username = github_username
|
24
|
+
def initialize(github_repo_name, options = {})
|
25
|
+
check_user_git_config()
|
26
26
|
|
27
27
|
if github_repo_name.nil?
|
28
28
|
raise NoGitHubRepoNameGiven
|
29
29
|
end
|
30
30
|
self.github_repo_name = github_repo_name
|
31
|
-
|
31
|
+
|
32
32
|
self.github_remote = "git@github.com:#{github_username}/#{github_repo_name}.git"
|
33
33
|
self.github_url = "http://github.com/#{github_username}/#{github_repo_name}"
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
self.target_dir = dir || self.github_repo_name
|
34
|
+
|
35
|
+
self.test_style = options[:test_style] || :shoulda
|
36
|
+
self.target_dir = options[:directory] || self.github_repo_name
|
38
37
|
self.lib_dir = File.join(target_dir, 'lib')
|
39
|
-
self.test_dir = File.join(target_dir, 'test')
|
40
38
|
self.constant_name = self.github_repo_name.split(/[-_]/).collect{|each| each.capitalize }.join
|
41
39
|
self.file_name_prefix = self.github_repo_name.gsub('-', '_')
|
42
40
|
end
|
@@ -45,14 +43,27 @@ class Jeweler
|
|
45
43
|
create_files
|
46
44
|
gitify
|
47
45
|
end
|
48
|
-
|
46
|
+
|
47
|
+
def testspec
|
48
|
+
case test_style
|
49
|
+
when :shoulda
|
50
|
+
'test'
|
51
|
+
when :bacon
|
52
|
+
'spec'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_dir
|
57
|
+
File.join(target_dir, testspec)
|
58
|
+
end
|
59
|
+
|
60
|
+
|
49
61
|
private
|
50
62
|
def create_files
|
51
|
-
|
63
|
+
unless File.exists?(target_dir) || File.directory?(target_dir)
|
52
64
|
FileUtils.mkdir target_dir
|
53
|
-
|
54
|
-
|
55
|
-
exit 1
|
65
|
+
else
|
66
|
+
raise FileInTheWay, "The directory #{target_dir} already exists, aborting. Maybe move it out of the way before continuing?"
|
56
67
|
end
|
57
68
|
|
58
69
|
FileUtils.mkdir lib_dir
|
@@ -62,27 +73,35 @@ class Jeweler
|
|
62
73
|
output_template_in_target('Rakefile')
|
63
74
|
output_template_in_target('LICENSE')
|
64
75
|
output_template_in_target('README')
|
65
|
-
output_template_in_target(
|
66
|
-
output_template_in_target(
|
67
|
-
|
76
|
+
output_template_in_target("#{testspec}/#{testspec}_helper.rb")
|
77
|
+
output_template_in_target("#{testspec}/flunking_#{testspec}.rb", "#{testspec}/#{file_name_prefix}_#{testspec}.rb")
|
78
|
+
|
68
79
|
FileUtils.touch File.join(lib_dir, "#{file_name_prefix}.rb")
|
69
80
|
end
|
70
|
-
|
81
|
+
|
71
82
|
def check_user_git_config
|
72
|
-
config = read_git_config
|
83
|
+
self.config = read_git_config
|
84
|
+
|
73
85
|
unless config.has_key? 'user.name'
|
74
86
|
raise NoGitUserName, %Q{No user.name set in ~/.gitconfig. Set it with: git config --global user.name 'Your Name Here'}
|
75
87
|
end
|
88
|
+
|
76
89
|
unless config.has_key? 'user.email'
|
77
90
|
raise NoGitUserEmail, %Q{No user.name set in ~/.gitconfig. Set it with: git config --global user.name 'Your Name Here'}
|
78
91
|
end
|
92
|
+
|
93
|
+
unless config.has_key? 'github.user'
|
94
|
+
raise NoGitHubUser, %Q{No github.user set in ~/.gitconfig. Set it with: git config --global github.user 'Your username here'}
|
95
|
+
end
|
79
96
|
|
80
97
|
self.user_name = config['user.name']
|
81
98
|
self.user_email = config['user.email']
|
99
|
+
self.github_username = config['github.user']
|
82
100
|
end
|
83
|
-
|
101
|
+
|
84
102
|
def output_template_in_target(source, destination = source)
|
85
103
|
template = ERB.new(File.read(File.join(File.dirname(__FILE__), 'templates', source)))
|
104
|
+
|
86
105
|
File.open(File.join(target_dir, destination), 'w') {|file| file.write(template.result(binding))}
|
87
106
|
end
|
88
107
|
|
@@ -90,18 +109,36 @@ class Jeweler
|
|
90
109
|
saved_pwd = Dir.pwd
|
91
110
|
Dir.chdir(target_dir)
|
92
111
|
begin
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
112
|
+
begin
|
113
|
+
repo = Git.init()
|
114
|
+
rescue Git::GitExecuteError => e
|
115
|
+
raise GitInitFailed, "Encountered an error during gitification. Maybe the repo already exists, or has already been pushed to?"
|
116
|
+
end
|
117
|
+
|
118
|
+
begin
|
119
|
+
repo.add('.')
|
120
|
+
rescue Git::GitExecuteError => e
|
121
|
+
#raise GitAddFailed, "There was some problem adding this directory to the git changeset"
|
122
|
+
raise
|
123
|
+
end
|
124
|
+
|
125
|
+
begin
|
126
|
+
repo.commit "Initial commit to #{github_repo_name}."
|
127
|
+
rescue Git::GitExecuteError => e
|
128
|
+
raise
|
129
|
+
end
|
130
|
+
|
131
|
+
begin
|
132
|
+
repo.add_remote('origin', github_remote)
|
133
|
+
rescue Git::GitExecuteError => e
|
134
|
+
puts "Encountered an error while adding origin remote. Maybe you have some weird settings in ~/.gitconfig?"
|
135
|
+
raise
|
136
|
+
end
|
137
|
+
ensure
|
138
|
+
Dir.chdir(saved_pwd)
|
101
139
|
end
|
102
|
-
Dir.chdir(saved_pwd)
|
103
140
|
end
|
104
|
-
|
141
|
+
|
105
142
|
def read_git_config
|
106
143
|
# we could just use Git::Base's .config, but that relies on a repo being around already
|
107
144
|
# ... which we don't have yet, since this is part of a sanity check
|
@@ -109,4 +146,4 @@ class Jeweler
|
|
109
146
|
config = lib.parse_config '~/.gitconfig'
|
110
147
|
end
|
111
148
|
end
|
112
|
-
end
|
149
|
+
end
|
data/lib/jeweler/release.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
class Jeweler
|
2
2
|
module Release
|
3
|
-
|
3
|
+
|
4
4
|
def release
|
5
5
|
@repo.checkout('master')
|
6
|
-
|
6
|
+
|
7
7
|
raise "Hey buddy, try committing them files first" if any_pending_changes?
|
8
|
-
|
8
|
+
|
9
9
|
write_gemspec()
|
10
|
-
|
10
|
+
|
11
11
|
@repo.add(gemspec_path)
|
12
12
|
@repo.commit("Regenerated gemspec for version #{version}")
|
13
13
|
@repo.push
|
14
|
-
|
14
|
+
|
15
15
|
@repo.add_tag(release_tag)
|
16
16
|
@repo.push('origin', release_tag)
|
17
17
|
end
|
@@ -19,10 +19,10 @@ class Jeweler
|
|
19
19
|
def release_tag
|
20
20
|
@release_tag ||= "v#{version}"
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
protected
|
24
24
|
def any_pending_changes?
|
25
|
-
@repo.status.added.empty? && @repo.status.deleted.empty? && @repo.status.changed.empty? && @repo.status.untracked.empty?
|
25
|
+
!(@repo.status.added.empty? && @repo.status.deleted.empty? && @repo.status.changed.empty? && @repo.status.untracked.empty?)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
data/lib/jeweler/tasks.rb
CHANGED
@@ -4,14 +4,14 @@ require 'rake/tasklib'
|
|
4
4
|
class Jeweler
|
5
5
|
class Tasks < ::Rake::TaskLib
|
6
6
|
def initialize(gemspec = nil, &block)
|
7
|
-
@gemspec = Gem::Specification.new()
|
8
|
-
|
7
|
+
@gemspec = gemspec || Gem::Specification.new()
|
8
|
+
yield @gemspec if block_given?
|
9
9
|
|
10
10
|
@jeweler = Jeweler.new(@gemspec)
|
11
|
-
|
11
|
+
|
12
12
|
define_tasks
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
private
|
16
16
|
def ensure_version_yml(&block)
|
17
17
|
unless File.exists? 'VERSION.yml'
|
@@ -19,7 +19,7 @@ class Jeweler
|
|
19
19
|
end
|
20
20
|
block.call if block
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def define_tasks
|
24
24
|
desc "Generate and validates gemspec"
|
25
25
|
task :gemspec => ['gemspec:generate', 'gemspec:validate']
|
@@ -77,12 +77,12 @@ class Jeweler
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
desc "Release the current version. Includes updating the gemspec, pushing, and tagging the release"
|
82
82
|
task :release do
|
83
83
|
@jeweler.release
|
84
84
|
end
|
85
|
-
|
85
|
+
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
@@ -19,21 +19,21 @@ end
|
|
19
19
|
|
20
20
|
Rake::TestTask.new do |t|
|
21
21
|
t.libs << 'lib'
|
22
|
-
t.pattern = '
|
22
|
+
t.pattern = '<%= testspec %>/**/*_<%= testspec %>.rb'
|
23
23
|
t.verbose = false
|
24
24
|
end
|
25
25
|
|
26
26
|
Rake::RDocTask.new do |rdoc|
|
27
27
|
rdoc.rdoc_dir = 'rdoc'
|
28
|
-
rdoc.title = '
|
28
|
+
rdoc.title = '<%= github_repo_name %>'
|
29
29
|
rdoc.options << '--line-numbers' << '--inline-source'
|
30
30
|
rdoc.rdoc_files.include('README*')
|
31
31
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
32
32
|
end
|
33
33
|
|
34
34
|
Rcov::RcovTask.new do |t|
|
35
|
-
t.libs << "
|
36
|
-
t.test_files = FileList['
|
35
|
+
t.libs << "<%= testspec %>"
|
36
|
+
t.test_files = FileList['<%= testspec %>/**/*_<%= testspec %>.rb']
|
37
37
|
t.verbose = true
|
38
38
|
end
|
39
39
|
|
data/lib/jeweler/versioning.rb
CHANGED
@@ -23,18 +23,18 @@ class Jeweler
|
|
23
23
|
def version
|
24
24
|
"#{major_version}.#{minor_version}.#{patch_version}"
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
protected
|
28
28
|
def version_yaml_path
|
29
29
|
denormalized_path = File.join(@base_dir, 'VERSION.yml')
|
30
30
|
absolute_path = File.expand_path(denormalized_path)
|
31
31
|
absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
def version_yaml
|
35
35
|
@version_yaml ||= read_version_yaml
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
def read_version_yaml
|
39
39
|
if File.exists?(version_yaml_path)
|
40
40
|
YAML.load_file(version_yaml_path)
|
@@ -42,7 +42,7 @@ class Jeweler
|
|
42
42
|
raise VersionYmlError, "#{version_yaml_path} does not exist!"
|
43
43
|
end
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
def refresh_version
|
47
47
|
@version_yaml = read_version_yaml
|
48
48
|
end
|
data/lib/jeweler.rb
CHANGED
@@ -15,17 +15,17 @@ class Jeweler
|
|
15
15
|
include Jeweler::Versioning
|
16
16
|
include Jeweler::Gemspec
|
17
17
|
include Jeweler::Release
|
18
|
-
|
18
|
+
|
19
19
|
attr_reader :gemspec
|
20
20
|
attr_accessor :base_dir
|
21
|
-
|
21
|
+
|
22
22
|
def initialize(gemspec, base_dir = '.')
|
23
23
|
raise(GemspecError, "Can't create a Jeweler with a nil gemspec") if gemspec.nil?
|
24
24
|
@gemspec = gemspec
|
25
25
|
@base_dir = base_dir
|
26
|
-
|
26
|
+
|
27
27
|
@gemspec.files ||= FileList["[A-Z]*.*", "{bin,generators,lib,test,spec}/**/*"]
|
28
|
-
|
28
|
+
|
29
29
|
if File.exists?(File.join(base_dir, '.git'))
|
30
30
|
@repo = Git.open(base_dir)
|
31
31
|
end
|
@@ -1,21 +1,21 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/test_helper'
|
2
2
|
|
3
3
|
class JewelerTest < Test::Unit::TestCase
|
4
|
-
|
4
|
+
|
5
5
|
def self.should_create_directory(directory)
|
6
6
|
should "create #{directory} directory" do
|
7
7
|
assert File.exists?(File.join(@tmp_dir, directory))
|
8
8
|
assert File.directory?(File.join(@tmp_dir, directory))
|
9
9
|
end
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def self.should_create_file(file)
|
13
13
|
should "create file #{file}" do
|
14
14
|
assert File.exists?(File.join(@tmp_dir, file))
|
15
15
|
assert File.file?(File.join(@tmp_dir, file))
|
16
16
|
end
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def self.should_be_checked_in(file)
|
20
20
|
should "have #{file} checked in" do
|
21
21
|
status = @repo.status[file]
|
@@ -24,22 +24,10 @@ class JewelerTest < Test::Unit::TestCase
|
|
24
24
|
assert_nil status.type, "#{file} had a type. it should have been nil"
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
28
|
-
context "given a nil github username" do
|
29
|
-
setup do
|
30
|
-
@block = lambda { Jeweler::Generator.new(nil, 'the-perfect-gem', nil) }
|
31
|
-
end
|
32
27
|
|
33
|
-
should "raise an error" do
|
34
|
-
assert_raise Jeweler::NoGitHubUsernameGiven do
|
35
|
-
@block.call
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
28
|
context "given a nil github repo name" do
|
41
29
|
setup do
|
42
|
-
@block = lambda { Jeweler::Generator.new(
|
30
|
+
@block = lambda { Jeweler::Generator.new(nil) }
|
43
31
|
end
|
44
32
|
|
45
33
|
should "raise an error" do
|
@@ -48,15 +36,15 @@ class JewelerTest < Test::Unit::TestCase
|
|
48
36
|
end
|
49
37
|
end
|
50
38
|
end
|
51
|
-
|
39
|
+
|
52
40
|
context "without git user's name set" do
|
53
41
|
setup do
|
54
42
|
Jeweler::Generator.any_instance.stubs(:read_git_config).returns({'user.email' => 'bar@example.com'})
|
55
43
|
end
|
56
|
-
|
44
|
+
|
57
45
|
context "instantiating new generator" do
|
58
46
|
setup do
|
59
|
-
@block = lambda { Jeweler::Generator.new('
|
47
|
+
@block = lambda { Jeweler::Generator.new('the-perfect-gem')}
|
60
48
|
end
|
61
49
|
|
62
50
|
should "raise no git user name exception" do
|
@@ -66,7 +54,7 @@ class JewelerTest < Test::Unit::TestCase
|
|
66
54
|
end
|
67
55
|
end
|
68
56
|
end
|
69
|
-
|
57
|
+
|
70
58
|
context "without git user's email set" do
|
71
59
|
setup do
|
72
60
|
Jeweler::Generator.any_instance.stubs(:read_git_config).returns({'user.name' => 'foo'})
|
@@ -74,7 +62,7 @@ class JewelerTest < Test::Unit::TestCase
|
|
74
62
|
|
75
63
|
context "instantiating new generator" do
|
76
64
|
setup do
|
77
|
-
@block = lambda { Jeweler::Generator.new('
|
65
|
+
@block = lambda { Jeweler::Generator.new('the-perfect-gem')}
|
78
66
|
end
|
79
67
|
|
80
68
|
should "raise no git user name exception" do
|
@@ -84,21 +72,41 @@ class JewelerTest < Test::Unit::TestCase
|
|
84
72
|
end
|
85
73
|
end
|
86
74
|
end
|
87
|
-
|
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
|
+
|
88
95
|
context "with valid git user configuration" do
|
89
96
|
setup do
|
90
|
-
Jeweler::Generator.any_instance.stubs(:read_git_config).
|
97
|
+
Jeweler::Generator.any_instance.stubs(:read_git_config).
|
98
|
+
returns({'user.name' => 'foo', 'user.email' => 'bar@example.com', 'github.user' => 'technicalpickles'})
|
91
99
|
end
|
92
|
-
|
100
|
+
|
93
101
|
context "for technicalpickle's the-perfect-gem repository" do
|
94
102
|
setup do
|
95
|
-
@generator = Jeweler::Generator.new('
|
103
|
+
@generator = Jeweler::Generator.new('the-perfect-gem')
|
96
104
|
end
|
97
|
-
|
105
|
+
|
98
106
|
should "assign 'foo' to user's name" do
|
99
107
|
assert_equal 'foo', @generator.user_name
|
100
108
|
end
|
101
|
-
|
109
|
+
|
102
110
|
should "assign 'bar@example.com to user's email" do
|
103
111
|
assert_equal 'bar@example.com', @generator.user_email
|
104
112
|
end
|
@@ -106,63 +114,63 @@ class JewelerTest < Test::Unit::TestCase
|
|
106
114
|
should "assign github remote" do
|
107
115
|
assert_equal 'git@github.com:technicalpickles/the-perfect-gem.git', @generator.github_remote
|
108
116
|
end
|
109
|
-
|
117
|
+
|
110
118
|
should "determine github username as technicalpickles" do
|
111
119
|
assert_equal 'technicalpickles', @generator.github_username
|
112
120
|
end
|
113
|
-
|
121
|
+
|
114
122
|
should "determine github repository name as the-perfect-gem" do
|
115
123
|
assert_equal 'the-perfect-gem', @generator.github_repo_name
|
116
124
|
end
|
117
|
-
|
125
|
+
|
118
126
|
should "determine github url as http://github.com/technicalpickles/the-perfect-gem" do
|
119
127
|
assert_equal 'http://github.com/technicalpickles/the-perfect-gem', @generator.github_url
|
120
128
|
end
|
121
|
-
|
129
|
+
|
122
130
|
should "determine target directory as the same as the github repository name" do
|
123
131
|
assert_equal @generator.github_repo_name, @generator.target_dir
|
124
132
|
end
|
125
|
-
|
133
|
+
|
126
134
|
should "determine lib directory as being inside the target directory" do
|
127
135
|
assert_equal File.join(@generator.target_dir, 'lib'), @generator.lib_dir
|
128
136
|
end
|
129
|
-
|
137
|
+
|
130
138
|
should "determine test directory as being inside the target directory" do
|
131
139
|
assert_equal File.join(@generator.target_dir, 'test'), @generator.test_dir
|
132
140
|
end
|
133
|
-
|
141
|
+
|
134
142
|
should "determine constant name as ThePerfectGem" do
|
135
143
|
assert_equal 'ThePerfectGem', @generator.constant_name
|
136
144
|
end
|
137
|
-
|
145
|
+
|
138
146
|
should "determine file name prefix as the_perfect_gem" do
|
139
147
|
assert_equal 'the_perfect_gem', @generator.file_name_prefix
|
140
148
|
end
|
141
149
|
end
|
142
|
-
|
143
|
-
|
150
|
+
|
151
|
+
|
144
152
|
context "and cleaned out tmp directory" do
|
145
153
|
setup do
|
146
154
|
@tmp_dir = File.join(File.dirname(__FILE__), 'tmp')
|
147
155
|
FileUtils.rm_rf(@tmp_dir)
|
148
|
-
|
156
|
+
|
149
157
|
assert ! File.exists?(@tmp_dir)
|
150
158
|
end
|
151
159
|
|
152
160
|
teardown do
|
153
161
|
FileUtils.rm_rf(@tmp_dir)
|
154
162
|
end
|
155
|
-
|
163
|
+
|
156
164
|
context "for technicalpickles's the-perfect-gem repo and working directory 'tmp'" do
|
157
165
|
setup do
|
158
|
-
@generator = Jeweler::Generator.new('
|
166
|
+
@generator = Jeweler::Generator.new('the-perfect-gem', :directory => @tmp_dir)
|
159
167
|
end
|
160
168
|
|
161
169
|
should "use tmp for target directory" do
|
162
170
|
assert_equal @tmp_dir, @generator.target_dir
|
163
171
|
end
|
164
|
-
|
165
|
-
context "running" do
|
172
|
+
|
173
|
+
context "running for spec = false" do
|
166
174
|
setup do
|
167
175
|
@generator.run
|
168
176
|
end
|
@@ -170,17 +178,17 @@ class JewelerTest < Test::Unit::TestCase
|
|
170
178
|
should 'create target directory' do
|
171
179
|
assert File.exists?(@tmp_dir)
|
172
180
|
end
|
173
|
-
|
181
|
+
|
174
182
|
should_create_directory 'lib'
|
175
183
|
should_create_directory 'test'
|
176
|
-
|
184
|
+
|
177
185
|
should_create_file 'LICENSE'
|
178
186
|
should_create_file 'README'
|
179
187
|
should_create_file 'lib/the_perfect_gem.rb'
|
180
188
|
should_create_file 'test/test_helper.rb'
|
181
189
|
should_create_file 'test/the_perfect_gem_test.rb'
|
182
190
|
should_create_file '.gitignore'
|
183
|
-
|
191
|
+
|
184
192
|
context "LICENSE" do
|
185
193
|
setup do
|
186
194
|
@content = File.read((File.join(@tmp_dir, 'LICENSE')))
|
@@ -190,25 +198,37 @@ class JewelerTest < Test::Unit::TestCase
|
|
190
198
|
assert_match 'Copyright (c) 2008 foo', @content
|
191
199
|
end
|
192
200
|
end
|
193
|
-
|
201
|
+
|
194
202
|
context "Rakefile" do
|
195
203
|
setup do
|
196
204
|
@content = File.read((File.join(@tmp_dir, 'Rakefile')))
|
197
205
|
end
|
198
|
-
|
206
|
+
|
199
207
|
should "include repo's name as the gem's name" do
|
200
208
|
assert_match 's.name = "the-perfect-gem"', @content
|
201
209
|
end
|
202
|
-
|
210
|
+
|
203
211
|
should "include the user's email as the gem's email" do
|
204
212
|
assert_match 's.email = "bar@example.com"', @content
|
205
213
|
end
|
206
|
-
|
214
|
+
|
207
215
|
should "include the github repo's url as the gem's url" do
|
208
216
|
assert_match 's.homepage = "http://github.com/technicalpickles/the-perfect-gem"', @content
|
209
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
|
210
230
|
end
|
211
|
-
|
231
|
+
|
212
232
|
context ".gitignore" do
|
213
233
|
setup do
|
214
234
|
@content = File.read((File.join(@tmp_dir, '.gitignore')))
|
@@ -217,17 +237,17 @@ class JewelerTest < Test::Unit::TestCase
|
|
217
237
|
should "include vim swap files" do
|
218
238
|
assert_match '*.sw?', @content
|
219
239
|
end
|
220
|
-
|
240
|
+
|
221
241
|
should "include coverage" do
|
222
242
|
assert_match 'coverage', @content
|
223
243
|
end
|
224
|
-
|
244
|
+
|
225
245
|
should "include .DS_Store" do
|
226
246
|
assert_match '.DS_Store', @content
|
227
247
|
end
|
228
248
|
end
|
229
|
-
|
230
|
-
|
249
|
+
|
250
|
+
|
231
251
|
context "test/the_perfect_gem_test.rb" do
|
232
252
|
setup do
|
233
253
|
@content = File.read((File.join(@tmp_dir, 'test', 'the_perfect_gem_test.rb')))
|
@@ -237,8 +257,8 @@ class JewelerTest < Test::Unit::TestCase
|
|
237
257
|
assert_match 'class ThePerfectGemTest < Test::Unit::TestCase', @content
|
238
258
|
end
|
239
259
|
end
|
240
|
-
|
241
|
-
|
260
|
+
|
261
|
+
|
242
262
|
context "created git repo" do
|
243
263
|
setup do
|
244
264
|
@repo = Git.open(@tmp_dir)
|
@@ -247,12 +267,12 @@ class JewelerTest < Test::Unit::TestCase
|
|
247
267
|
should 'have one commit log' do
|
248
268
|
assert_equal 1, @repo.log.size
|
249
269
|
end
|
250
|
-
|
270
|
+
|
251
271
|
should "have one commit log an initial commit message" do
|
252
272
|
# TODO message seems to include leading whitespace, could probably fix that in ruby-git
|
253
273
|
assert_match 'Initial commit to the-perfect-gem.', @repo.log.first.message
|
254
274
|
end
|
255
|
-
|
275
|
+
|
256
276
|
should_be_checked_in 'README'
|
257
277
|
should_be_checked_in 'Rakefile'
|
258
278
|
should_be_checked_in 'LICENSE'
|
@@ -260,24 +280,162 @@ class JewelerTest < Test::Unit::TestCase
|
|
260
280
|
should_be_checked_in 'test/test_helper.rb'
|
261
281
|
should_be_checked_in 'test/the_perfect_gem_test.rb'
|
262
282
|
should_be_checked_in '.gitignore'
|
263
|
-
|
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 bacon" do
|
311
|
+
setup do
|
312
|
+
@generator.test_style = :bacon
|
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
|
+
|
264
422
|
should "have no untracked files" do
|
265
423
|
assert_equal 0, @repo.status.untracked.size
|
266
424
|
end
|
267
|
-
|
425
|
+
|
268
426
|
should "have no changed files" do
|
269
427
|
assert_equal 0, @repo.status.changed.size
|
270
428
|
end
|
271
|
-
|
429
|
+
|
272
430
|
should "have no added files" do
|
273
431
|
assert_equal 0, @repo.status.added.size
|
274
432
|
end
|
275
|
-
|
433
|
+
|
276
434
|
should "have no deleted files" do
|
277
435
|
assert_equal 0, @repo.status.deleted.size
|
278
436
|
end
|
279
437
|
|
280
|
-
|
438
|
+
|
281
439
|
should "have git@github.com:technicalpickles/the-perfect-gem.git as origin remote" do
|
282
440
|
assert_equal 1, @repo.remotes.size
|
283
441
|
remote = @repo.remotes.first
|
@@ -289,5 +447,5 @@ class JewelerTest < Test::Unit::TestCase
|
|
289
447
|
end
|
290
448
|
end
|
291
449
|
end
|
292
|
-
|
450
|
+
|
293
451
|
end
|
data/test/jeweler_test.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/test_helper'
|
2
2
|
|
3
3
|
class JewelerTest < Test::Unit::TestCase
|
4
|
-
|
4
|
+
|
5
5
|
def setup
|
6
6
|
@now = Time.now
|
7
7
|
Time.stubs(:now).returns(@now)
|
8
|
+
FileUtils.rm_rf("#{File.dirname(__FILE__)}/tmp")
|
8
9
|
end
|
9
|
-
|
10
|
+
|
10
11
|
def teardown
|
11
12
|
FileUtils.rm_rf("#{File.dirname(__FILE__)}/tmp")
|
12
13
|
end
|
13
|
-
|
14
|
+
|
14
15
|
def build_spec
|
15
16
|
Gem::Specification.new do |s|
|
16
17
|
s.name = "bar"
|
@@ -22,75 +23,38 @@ class JewelerTest < Test::Unit::TestCase
|
|
22
23
|
s.files = FileList["[A-Z]*", "{generators,lib,test}/**/*"]
|
23
24
|
end
|
24
25
|
end
|
25
|
-
|
26
|
-
class << self
|
27
|
-
def should_have_major_version(version)
|
28
|
-
should "have major version of #{version}" do
|
29
|
-
assert_equal version, @jeweler.major_version
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def should_have_minor_version(version)
|
34
|
-
should "have minor version of #{version}" do
|
35
|
-
assert_equal version, @jeweler.minor_version
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def should_have_patch_version(version)
|
40
|
-
should "have patch version of #{version}" do
|
41
|
-
assert_equal version, @jeweler.patch_version
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def should_be_version(version)
|
46
|
-
should "be version #{version}" do
|
47
|
-
assert_equal version, @jeweler.version
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def should_bump_version(major, minor, patch)
|
52
|
-
version = "#{major}.#{minor}.#{patch}"
|
53
|
-
should_have_major_version major
|
54
|
-
should_have_minor_version minor
|
55
|
-
should_have_patch_version patch
|
56
|
-
should_be_version version
|
57
|
-
should "output the new version, #{version}" do
|
58
|
-
assert_match version, @output
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
26
|
+
|
63
27
|
context "A jeweler without a VERSION.yml" do
|
64
28
|
setup do
|
65
29
|
FileUtils.mkdir_p(tmp_dir)
|
66
30
|
@jeweler = Jeweler.new(build_spec, tmp_dir)
|
67
31
|
end
|
68
|
-
|
32
|
+
|
69
33
|
should "not have VERSION.yml" do
|
70
34
|
assert ! File.exists?(File.join(tmp_dir, 'bar.gemspec'))
|
71
35
|
end
|
72
36
|
end
|
73
|
-
|
74
|
-
|
37
|
+
|
38
|
+
|
75
39
|
context "A Jeweler with a VERSION.yml" do
|
76
40
|
setup do
|
77
41
|
FileUtils.cp_r(fixture_dir, tmp_dir)
|
78
42
|
|
79
43
|
@jeweler = Jeweler.new(build_spec, tmp_dir)
|
80
|
-
end
|
81
|
-
|
44
|
+
end
|
45
|
+
|
82
46
|
should_have_major_version 1
|
83
47
|
should_have_minor_version 5
|
84
48
|
should_have_patch_version 2
|
85
49
|
should_be_version '1.5.2'
|
86
|
-
|
50
|
+
|
87
51
|
context "bumping the patch version" do
|
88
52
|
setup do
|
89
53
|
@output = catch_out { @jeweler.bump_patch_version }
|
90
54
|
end
|
91
55
|
should_bump_version 1, 5, 3
|
92
56
|
end
|
93
|
-
|
57
|
+
|
94
58
|
context "bumping the minor version" do
|
95
59
|
setup do
|
96
60
|
@output = catch_out { @jeweler.bump_minor_version }
|
@@ -98,7 +62,7 @@ class JewelerTest < Test::Unit::TestCase
|
|
98
62
|
|
99
63
|
should_bump_version 1, 6, 0
|
100
64
|
end
|
101
|
-
|
65
|
+
|
102
66
|
context "bumping the major version" do
|
103
67
|
setup do
|
104
68
|
@output = catch_out { @jeweler.bump_major_version}
|
@@ -106,12 +70,12 @@ class JewelerTest < Test::Unit::TestCase
|
|
106
70
|
|
107
71
|
should_bump_version 2, 0, 0
|
108
72
|
end
|
109
|
-
|
73
|
+
|
110
74
|
context "writing the gemspec" do
|
111
75
|
setup do
|
112
76
|
@output = catch_out { @jeweler.write_gemspec }
|
113
77
|
end
|
114
|
-
|
78
|
+
|
115
79
|
should "create bar.gemspec" do
|
116
80
|
assert File.exists?(File.join(tmp_dir, 'bar.gemspec'))
|
117
81
|
end
|
@@ -119,12 +83,11 @@ class JewelerTest < Test::Unit::TestCase
|
|
119
83
|
should "have created a valid gemspec" do
|
120
84
|
assert @jeweler.valid_gemspec?
|
121
85
|
end
|
122
|
-
|
86
|
+
|
123
87
|
should "output the name of the gemspec" do
|
124
88
|
assert_match 'bar.gemspec', @output
|
125
89
|
end
|
126
|
-
|
127
|
-
|
90
|
+
|
128
91
|
context "re-reading the gemspec" do
|
129
92
|
setup do
|
130
93
|
gemspec_path = File.join(tmp_dir, 'bar.gemspec')
|
@@ -136,18 +99,18 @@ class JewelerTest < Test::Unit::TestCase
|
|
136
99
|
should "have version 1.5.2" do
|
137
100
|
assert_equal '1.5.2', @parsed_spec.version.version
|
138
101
|
end
|
139
|
-
|
102
|
+
|
140
103
|
should "have date filled in" do
|
141
104
|
assert_equal Time.local(@now.year, @now.month, @now.day), @parsed_spec.date
|
142
105
|
end
|
143
106
|
end
|
144
107
|
end
|
145
108
|
end
|
146
|
-
|
109
|
+
|
147
110
|
should "raise an exception when created with a nil gemspec" do
|
148
111
|
assert_raises Jeweler::GemspecError do
|
149
112
|
@jeweler = Jeweler.new(nil, tmp_dir)
|
150
113
|
end
|
151
114
|
end
|
152
|
-
|
115
|
+
|
153
116
|
end
|
@@ -0,0 +1,38 @@
|
|
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
|
+
should "output the new version, #{version}" do
|
34
|
+
assert_match version, @output
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -8,14 +8,16 @@ require 'ruby-debug'
|
|
8
8
|
gem 'mocha'
|
9
9
|
require 'mocha'
|
10
10
|
|
11
|
+
require File.dirname(__FILE__) + '/shoulda_macros/jeweler_macros'
|
12
|
+
|
11
13
|
# Use vendored gem because of limited gem availability on runcoderun
|
12
14
|
# This is loosely based on 'vendor everything'.
|
13
|
-
Dir[File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', '**')].each do |dir|
|
15
|
+
Dir[File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', '**')].each do |dir|
|
14
16
|
lib = "#{dir}/lib"
|
15
17
|
$LOAD_PATH.unshift(lib) if File.directory?(lib)
|
16
18
|
end
|
17
|
-
require 'output_catcher'
|
18
19
|
|
20
|
+
require 'output_catcher'
|
19
21
|
require 'time'
|
20
22
|
|
21
23
|
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
|
@@ -28,19 +30,21 @@ class FileList
|
|
28
30
|
end
|
29
31
|
end
|
30
32
|
|
33
|
+
TMP_DIR = File.join(File.dirname(__FILE__), 'tmp')
|
34
|
+
FileUtils.rm_f(TMP_DIR) # GAH, dirty hax. Somewhere isn't tearing up correctly, so do some cleanup first
|
35
|
+
|
31
36
|
class Test::Unit::TestCase
|
32
|
-
|
33
37
|
def catch_out(&block)
|
34
38
|
OutputCatcher.catch_out do
|
35
39
|
block.call
|
36
40
|
end
|
37
41
|
end
|
38
|
-
|
42
|
+
|
39
43
|
def fixture_dir
|
40
44
|
File.join(File.dirname(__FILE__), 'fixtures', 'bar')
|
41
45
|
end
|
42
|
-
|
46
|
+
|
43
47
|
def tmp_dir
|
44
48
|
File.join(File.dirname(__FILE__), 'tmp')
|
45
49
|
end
|
46
|
-
end
|
50
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: technicalpickles-jeweler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Nichols
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-11-
|
12
|
+
date: 2008-11-18 00:00:00 -08:00
|
13
13
|
default_executable: jeweler
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -46,6 +46,9 @@ files:
|
|
46
46
|
- lib/jeweler/templates/LICENSE
|
47
47
|
- lib/jeweler/templates/Rakefile
|
48
48
|
- lib/jeweler/templates/README
|
49
|
+
- lib/jeweler/templates/spec
|
50
|
+
- lib/jeweler/templates/spec/flunking_spec.rb
|
51
|
+
- lib/jeweler/templates/spec/spec_helper.rb
|
49
52
|
- lib/jeweler/templates/test
|
50
53
|
- lib/jeweler/templates/test/flunking_test.rb
|
51
54
|
- lib/jeweler/templates/test/test_helper.rb
|
@@ -56,6 +59,8 @@ files:
|
|
56
59
|
- test/fixtures/bar/VERSION.yml
|
57
60
|
- test/jeweler_generator_test.rb
|
58
61
|
- test/jeweler_test.rb
|
62
|
+
- test/shoulda_macros
|
63
|
+
- test/shoulda_macros/jeweler_macros.rb
|
59
64
|
- test/test_helper.rb
|
60
65
|
- lib/jeweler/templates/.gitignore
|
61
66
|
has_rdoc: false
|