namelessjon-jeweler 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,153 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class JewelerTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @now = Time.now
7
+ Time.stubs(:now).returns(@now)
8
+ end
9
+
10
+ def teardown
11
+ FileUtils.rm_rf("#{File.dirname(__FILE__)}/tmp")
12
+ end
13
+
14
+ def build_spec
15
+ Gem::Specification.new do |s|
16
+ s.name = "bar"
17
+ s.summary = "Simple and opinionated helper for creating Rubygem projects on GitHub"
18
+ s.email = "josh@technicalpickles.com"
19
+ s.homepage = "http://github.com/technicalpickles/jeweler"
20
+ s.description = "Simple and opinionated helper for creating Rubygem projects on GitHub"
21
+ s.authors = ["Josh Nichols", "Dan Croak"]
22
+ s.files = FileList["[A-Z]*", "{generators,lib,test}/**/*"]
23
+ end
24
+ 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
+
63
+ context "A jeweler without a VERSION.yml" do
64
+ setup do
65
+ FileUtils.mkdir_p(tmp_dir)
66
+ @jeweler = Jeweler.new(build_spec, tmp_dir)
67
+ end
68
+
69
+ should "not have VERSION.yml" do
70
+ assert ! File.exists?(File.join(tmp_dir, 'bar.gemspec'))
71
+ end
72
+ end
73
+
74
+
75
+ context "A Jeweler with a VERSION.yml" do
76
+ setup do
77
+ FileUtils.cp_r(fixture_dir, tmp_dir)
78
+
79
+ @jeweler = Jeweler.new(build_spec, tmp_dir)
80
+ end
81
+
82
+ should_have_major_version 1
83
+ should_have_minor_version 5
84
+ should_have_patch_version 2
85
+ should_be_version '1.5.2'
86
+
87
+ context "bumping the patch version" do
88
+ setup do
89
+ @output = catch_out { @jeweler.bump_patch_version }
90
+ end
91
+ should_bump_version 1, 5, 3
92
+ end
93
+
94
+ context "bumping the minor version" do
95
+ setup do
96
+ @output = catch_out { @jeweler.bump_minor_version }
97
+ end
98
+
99
+ should_bump_version 1, 6, 0
100
+ end
101
+
102
+ context "bumping the major version" do
103
+ setup do
104
+ @output = catch_out { @jeweler.bump_major_version}
105
+ end
106
+
107
+ should_bump_version 2, 0, 0
108
+ end
109
+
110
+ context "writing the gemspec" do
111
+ setup do
112
+ @output = catch_out { @jeweler.write_gemspec }
113
+ end
114
+
115
+ should "create bar.gemspec" do
116
+ assert File.exists?(File.join(tmp_dir, 'bar.gemspec'))
117
+ end
118
+
119
+ should "have created a valid gemspec" do
120
+ assert @jeweler.valid_gemspec?
121
+ end
122
+
123
+ should "output the name of the gemspec" do
124
+ assert_match 'bar.gemspec', @output
125
+ end
126
+
127
+
128
+ context "re-reading the gemspec" do
129
+ setup do
130
+ gemspec_path = File.join(tmp_dir, 'bar.gemspec')
131
+ data = File.read(gemspec_path)
132
+
133
+ @parsed_spec = eval("$SAFE = 3\n#{data}", binding, gemspec_path)
134
+ end
135
+
136
+ should "have version 1.5.2" do
137
+ assert_equal '1.5.2', @parsed_spec.version.version
138
+ end
139
+
140
+ should "have date filled in" do
141
+ assert_equal Time.local(@now.year, @now.month, @now.day), @parsed_spec.date
142
+ end
143
+ end
144
+ end
145
+ end
146
+
147
+ should "raise an exception when created with a nil gemspec" do
148
+ assert_raises Jeweler::GemspecError do
149
+ @jeweler = Jeweler.new(nil, tmp_dir)
150
+ end
151
+ end
152
+
153
+ end
@@ -0,0 +1,46 @@
1
+ require 'test/unit'
2
+
3
+ require 'rubygems'
4
+ gem 'thoughtbot-shoulda'
5
+ require 'shoulda'
6
+ gem 'ruby-debug'
7
+ require 'ruby-debug'
8
+ gem 'mocha'
9
+ require 'mocha'
10
+
11
+ # Use vendored gem because of limited gem availability on runcoderun
12
+ # This is loosely based on 'vendor everything'.
13
+ Dir[File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', '**')].each do |dir|
14
+ lib = "#{dir}/lib"
15
+ $LOAD_PATH.unshift(lib) if File.directory?(lib)
16
+ end
17
+ require 'output_catcher'
18
+
19
+ require 'time'
20
+
21
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
22
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
23
+ require 'jeweler'
24
+
25
+ # Fake out FileList from Rake
26
+ class FileList
27
+ def self.[](*args)
28
+ end
29
+ end
30
+
31
+ class Test::Unit::TestCase
32
+
33
+ def catch_out(&block)
34
+ OutputCatcher.catch_out do
35
+ block.call
36
+ end
37
+ end
38
+
39
+ def fixture_dir
40
+ File.join(File.dirname(__FILE__), 'fixtures', 'bar')
41
+ end
42
+
43
+ def tmp_dir
44
+ File.join(File.dirname(__FILE__), 'tmp')
45
+ end
46
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: namelessjon-jeweler
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ platform: ruby
6
+ authors:
7
+ - Josh Nichols
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-16 00:00:00 -08:00
13
+ default_executable: jeweler
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: schacon-git
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "0"
23
+ version:
24
+ description: Simple and opinionated helper for creating Rubygem projects on GitHub
25
+ email: josh@technicalpickles.com
26
+ executables:
27
+ - jeweler
28
+ extensions: []
29
+
30
+ extra_rdoc_files: []
31
+
32
+ files:
33
+ - README.markdown
34
+ - Rakefile
35
+ - TODO
36
+ - VERSION.yml
37
+ - bin/jeweler
38
+ - lib/jeweler.rb
39
+ - lib/jeweler
40
+ - lib/jeweler/bumping.rb
41
+ - lib/jeweler/errors.rb
42
+ - lib/jeweler/gemspec.rb
43
+ - lib/jeweler/release.rb
44
+ - lib/jeweler/tasks.rb
45
+ - lib/jeweler/templates
46
+ - lib/jeweler/templates/LICENSE
47
+ - lib/jeweler/templates/README
48
+ - lib/jeweler/templates/test
49
+ - lib/jeweler/templates/test/flunking_test.rb
50
+ - lib/jeweler/templates/test/test_helper.rb
51
+ - lib/jeweler/templates/spec
52
+ - lib/jeweler/templates/spec/spec_helper.rb
53
+ - lib/jeweler/templates/spec/flunking_spec.rb
54
+ - lib/jeweler/templates/Rakefile
55
+ - lib/jeweler/versioning.rb
56
+ - lib/jeweler/generator.rb
57
+ - test/fixtures
58
+ - test/fixtures/bar
59
+ - test/fixtures/bar/VERSION.yml
60
+ - test/jeweler_test.rb
61
+ - test/test_helper.rb
62
+ - test/jeweler_generator_test.rb
63
+ - lib/jeweler/templates/.gitignore
64
+ has_rdoc: false
65
+ homepage: http://github.com/technicalpickles/jeweler
66
+ post_install_message:
67
+ rdoc_options: []
68
+
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: "0"
76
+ version:
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: "0"
82
+ version:
83
+ requirements: []
84
+
85
+ rubyforge_project:
86
+ rubygems_version: 1.2.0
87
+ signing_key:
88
+ specification_version: 2
89
+ summary: Simple and opinionated helper for creating Rubygem projects on GitHub
90
+ test_files: []
91
+