-
Notifications
You must be signed in to change notification settings - Fork 169
/
test_jeweler.rb
133 lines (102 loc) · 3.21 KB
/
test_jeweler.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
require File.dirname(__FILE__) + '/test_helper'
class TestJeweler < Test::Unit::TestCase
def setup
@now = Time.now
Time.stubs(:now).returns(@now)
FileUtils.rm_rf("#{File.dirname(__FILE__)}/tmp")
end
def teardown
FileUtils.rm_rf("#{File.dirname(__FILE__)}/tmp")
end
context "A jeweler without a VERSION.yml" do
setup do
FileUtils.mkdir_p(tmp_dir)
@jeweler = Jeweler.new(build_spec, tmp_dir)
end
should "not have VERSION.yml" do
assert ! File.exists?(File.join(tmp_dir, 'VERSION.yml'))
end
end
context "A Jeweler with a VERSION.yml" do
setup do
FileUtils.cp_r(fixture_dir, tmp_dir)
@jeweler = Jeweler.new(build_spec, tmp_dir)
end
should_have_major_version 1
should_have_minor_version 5
should_have_patch_version 2
should_be_version '1.5.2'
context "bumping the patch version" do
setup do
@output = catch_out { @jeweler.bump_patch_version }
end
should_bump_version 1, 5, 3
end
context "bumping the minor version" do
setup do
@output = catch_out { @jeweler.bump_minor_version }
end
should_bump_version 1, 6, 0
end
context "bumping the major version" do
setup do
@output = catch_out { @jeweler.bump_major_version}
end
should_bump_version 2, 0, 0
end
should "should find files" do
assert ! @jeweler.gemspec.files.empty?
end
context "with standard 'files' specified" do
setup do
@alt_jeweler = Jeweler.new(build_spec("[A-Z]*.*", "{bin,generators,lib,test,spec}/**/*"), tmp_dir)
end
should "have the same files as when no 'files' are specified" do
assert_equal @jeweler.gemspec.files, @alt_jeweler.gemspec.files
end
end
context "gemsepc's rdoc" do
should 'have be enabled' do
assert @jeweler.gemspec.has_rdoc
end
should 'do inline source' do
assert @jeweler.gemspec.rdoc_options.include?('--inline-source')
end
should 'be utf-8' do
assert @jeweler.gemspec.rdoc_options.include?('--charset=UTF-8')
end
end
context "writing the gemspec" do
setup do
@output = catch_out { @jeweler.write_gemspec }
end
should "create bar.gemspec" do
assert File.exists?(File.join(tmp_dir, 'bar.gemspec'))
end
should "have created a valid gemspec" do
assert @jeweler.valid_gemspec?
end
should "output the name of the gemspec" do
assert_match 'bar.gemspec', @output
end
context "re-reading the gemspec" do
setup do
gemspec_path = File.join(tmp_dir, 'bar.gemspec')
data = File.read(gemspec_path)
@parsed_spec = eval("$SAFE = 3\n#{data}", binding, gemspec_path)
end
should "have version 1.5.2" do
assert_equal '1.5.2', @parsed_spec.version.version
end
should "have date filled in" do
assert_equal Time.local(@now.year, @now.month, @now.day), @parsed_spec.date
end
end
end
end
should "raise an exception when created with a nil gemspec" do
assert_raises Jeweler::GemspecError do
@jeweler = Jeweler.new(nil, tmp_dir)
end
end
end