spec 5.0.14
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.
- checksums.yaml +7 -0
- data/.autotest +34 -0
- data/.gitignore +3 -0
- data/History.txt +911 -0
- data/Manifest.txt +26 -0
- data/README.txt +497 -0
- data/Rakefile +214 -0
- data/design_rationale.rb +52 -0
- data/lib/hoe/minitest.rb +26 -0
- data/lib/minitest/assertions.rb +649 -0
- data/lib/minitest/autorun.rb +12 -0
- data/lib/minitest/benchmark.rb +423 -0
- data/lib/minitest/expectations.rb +268 -0
- data/lib/minitest/hell.rb +11 -0
- data/lib/minitest/mock.rb +220 -0
- data/lib/minitest/parallel_each.rb +120 -0
- data/lib/minitest/pride.rb +4 -0
- data/lib/minitest/pride_plugin.rb +143 -0
- data/lib/minitest/spec.rb +292 -0
- data/lib/minitest/test.rb +272 -0
- data/lib/minitest/unit.rb +45 -0
- data/lib/minitest.rb +839 -0
- data/lib/spec.rb +3 -0
- data/readme.md +7 -0
- data/release_notes.md +49 -0
- data/spec.gemspec +36 -0
- data/test/manual/appium.rb +14 -0
- data/test/manual/appium_after_last.rb +24 -0
- data/test/manual/appium_before_first.rb +23 -0
- data/test/manual/assert.rb +61 -0
- data/test/manual/before_first_0.rb +27 -0
- data/test/manual/before_first_1.rb +29 -0
- data/test/manual/debug.rb +37 -0
- data/test/manual/do_end.rb +31 -0
- data/test/manual/raise.rb +61 -0
- data/test/manual/run2.rb +74 -0
- data/test/manual/run3.rb +91 -0
- data/test/manual/setup.rb +13 -0
- data/test/manual/simple.rb +19 -0
- data/test/manual/simple2.rb +20 -0
- data/test/manual/t.rb +11 -0
- data/test/manual/trace.rb +19 -0
- data/test/manual/trace2.rb +15 -0
- data/test/minitest/metametameta.rb +78 -0
- data/test/minitest/test_helper.rb +20 -0
- data/test/minitest/test_minitest_benchmark.rb +131 -0
- data/test/minitest/test_minitest_mock.rb +490 -0
- data/test/minitest/test_minitest_reporter.rb +270 -0
- data/test/minitest/test_minitest_spec.rb +794 -0
- data/test/minitest/test_minitest_unit.rb +1846 -0
- metadata +147 -0
data/Rakefile
ADDED
@@ -0,0 +1,214 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
|
6
|
+
Hoe.plugin :seattlerb
|
7
|
+
|
8
|
+
Hoe.spec 'minitest' do
|
9
|
+
developer 'Ryan Davis', 'ryand-ruby@zenspider.com'
|
10
|
+
|
11
|
+
self.rubyforge_name = "bfts"
|
12
|
+
self.testlib = :minitest
|
13
|
+
self.licenses = [ 'MIT' ]
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Find missing expectations"
|
17
|
+
task :specs do
|
18
|
+
$:.unshift "lib"
|
19
|
+
require "minitest/unit"
|
20
|
+
require "minitest/spec"
|
21
|
+
|
22
|
+
pos_prefix, neg_prefix = "must", "wont"
|
23
|
+
skip_re = /^(must|wont)$|wont_(throw)|must_(block|not?_|nothing|raise$)/x
|
24
|
+
dont_flip_re = /(must|wont)_(include|respond_to)/
|
25
|
+
|
26
|
+
map = {
|
27
|
+
/(must_throw)s/ => '\1',
|
28
|
+
/(?!not)_same/ => '_be_same_as',
|
29
|
+
/_in_/ => '_be_within_',
|
30
|
+
/_operator/ => '_be',
|
31
|
+
/_includes/ => '_include',
|
32
|
+
/(must|wont)_(.*_of|nil|silent|empty)/ => '\1_be_\2',
|
33
|
+
/must_raises/ => 'must_raise',
|
34
|
+
}
|
35
|
+
|
36
|
+
expectations = Minitest::Expectations.public_instance_methods.map(&:to_s)
|
37
|
+
assertions = Minitest::Assertions.public_instance_methods.map(&:to_s)
|
38
|
+
|
39
|
+
assertions.sort.each do |assertion|
|
40
|
+
expectation = case assertion
|
41
|
+
when /^assert/ then
|
42
|
+
assertion.sub(/^assert/, pos_prefix.to_s)
|
43
|
+
when /^refute/ then
|
44
|
+
assertion.sub(/^refute/, neg_prefix.to_s)
|
45
|
+
end
|
46
|
+
|
47
|
+
next unless expectation
|
48
|
+
next if expectation =~ skip_re
|
49
|
+
|
50
|
+
regexp, replacement = map.find { |re, _| expectation =~ re }
|
51
|
+
expectation.sub! regexp, replacement if replacement
|
52
|
+
|
53
|
+
next if expectations.include? expectation
|
54
|
+
|
55
|
+
args = [assertion, expectation].map(&:to_sym).map(&:inspect)
|
56
|
+
args << :reverse if expectation =~ dont_flip_re
|
57
|
+
|
58
|
+
puts
|
59
|
+
puts "##"
|
60
|
+
puts "# :method: #{expectation}"
|
61
|
+
puts "# See Minitest::Assertions##{assertion}"
|
62
|
+
puts
|
63
|
+
puts "infect_an_assertion #{args.join ", "}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# vim: syntax=Ruby
|
68
|
+
|
69
|
+
# from https://github.com/bootstraponline/gem_template
|
70
|
+
# todo: publish gem_template as a gem
|
71
|
+
|
72
|
+
# encoding: utf-8
|
73
|
+
require 'rubygems'
|
74
|
+
require 'rake'
|
75
|
+
require 'date'
|
76
|
+
|
77
|
+
# Defines gem name.
|
78
|
+
def repo_name; 'spec' end # rubygems.org name
|
79
|
+
def gh_name; "bootstraponline/#{repo_name}" end # username/reponame as used on github.com
|
80
|
+
def version_file; "lib/minitest.rb" end
|
81
|
+
def version_rgx; /VERSION = '([^']+)'/m end
|
82
|
+
|
83
|
+
def version
|
84
|
+
@version = @version || File.read(version_file).match(version_rgx)[1]
|
85
|
+
end
|
86
|
+
|
87
|
+
def bump
|
88
|
+
data = File.read version_file
|
89
|
+
|
90
|
+
v_line = data.match version_rgx
|
91
|
+
d_line = data.match /DATE = '([^']+)'/m
|
92
|
+
|
93
|
+
old_v = v_line[0]
|
94
|
+
old_d = d_line[0]
|
95
|
+
|
96
|
+
old_num = v_line[1]
|
97
|
+
new_num = old_num.split('.')
|
98
|
+
new_num[-1] = new_num[-1].to_i + 1
|
99
|
+
new_num = new_num.join '.'
|
100
|
+
|
101
|
+
new_v = old_v.sub old_num, new_num
|
102
|
+
puts "#{old_num} -> #{new_num}"
|
103
|
+
|
104
|
+
old_date = d_line[1]
|
105
|
+
new_date = Date.today.to_s
|
106
|
+
new_d = old_d.sub old_date, new_date
|
107
|
+
puts "#{old_date} -> #{new_date}" unless old_date == new_date
|
108
|
+
|
109
|
+
data.sub! old_v, new_v
|
110
|
+
data.sub! old_d, new_d
|
111
|
+
|
112
|
+
File.write version_file, data
|
113
|
+
end
|
114
|
+
|
115
|
+
desc 'Bump the version number and update the date.'
|
116
|
+
task :bump do
|
117
|
+
bump
|
118
|
+
end
|
119
|
+
|
120
|
+
desc 'Install gems required for release task'
|
121
|
+
task :dev do
|
122
|
+
sh 'gem install --no-rdoc --no-ri yard'
|
123
|
+
sh 'gem install --no-rdoc --no-ri redcarpet'
|
124
|
+
end
|
125
|
+
|
126
|
+
desc 'Install gem'
|
127
|
+
task :install => [ :b_gem, :uninstall ] do
|
128
|
+
sh "gem install --no-rdoc --no-ri --local #{repo_name}-#{version}.gem"
|
129
|
+
end
|
130
|
+
|
131
|
+
desc 'Build a new gem'
|
132
|
+
task :b_gem do
|
133
|
+
`chmod 0600 ~/.gem/credentials`
|
134
|
+
sh "gem build #{repo_name}.gemspec"
|
135
|
+
end
|
136
|
+
|
137
|
+
# Inspired by Gollum's Rakefile
|
138
|
+
desc 'Build and release a new gem to rubygems.org'
|
139
|
+
task :rel => :b_gem do
|
140
|
+
unless `git branch`.include? '* master'
|
141
|
+
puts 'Master branch required to release.'
|
142
|
+
exit!
|
143
|
+
end
|
144
|
+
|
145
|
+
# Commit then pull before pushing.
|
146
|
+
sh "git commit --allow-empty -am 'Release #{version}'"
|
147
|
+
sh 'git pull'
|
148
|
+
sh "git tag v#{version}"
|
149
|
+
# update notes now that there's a new tag
|
150
|
+
Rake::Task['notes'].execute
|
151
|
+
sh "git commit --allow-empty -am 'Update release notes'"
|
152
|
+
sh 'git push origin master'
|
153
|
+
sh "git push origin v#{version}"
|
154
|
+
sh "gem push #{repo_name}-#{version}.gem"
|
155
|
+
end
|
156
|
+
|
157
|
+
desc 'Uninstall gem'
|
158
|
+
task :uninstall do
|
159
|
+
cmd = "gem uninstall -aIx #{repo_name}"
|
160
|
+
puts cmd
|
161
|
+
# rescue on gem not installed error.
|
162
|
+
begin; `cmd`; rescue; end
|
163
|
+
end
|
164
|
+
|
165
|
+
desc 'Update release notes'
|
166
|
+
task :notes do
|
167
|
+
tag_sort = ->(tag1,tag2) do
|
168
|
+
tag1_numbers = tag1.match(/\.?v(\d+\.\d+\.\d+)$/)[1].split('.').map! { |n| n.to_i }
|
169
|
+
tag2_numbers = tag2.match(/\.?v(\d+\.\d+\.\d+)$/)[1].split('.').map! { |n| n.to_i }
|
170
|
+
tag1_numbers <=> tag2_numbers
|
171
|
+
end
|
172
|
+
|
173
|
+
tags = `git tag`.split "\n"
|
174
|
+
tags.sort! &tag_sort
|
175
|
+
pairs = []
|
176
|
+
tags.each_index { |a| pairs.push tags[a] + '...' + tags[a+1] unless tags[a+1].nil? }
|
177
|
+
|
178
|
+
notes = ''
|
179
|
+
|
180
|
+
dates = `git log --tags --simplify-by-decoration --pretty="format:%d %ad" --date=short`.split "\n"
|
181
|
+
|
182
|
+
pairs.sort! &tag_sort
|
183
|
+
pairs.reverse! # pairs are in reverse order.
|
184
|
+
|
185
|
+
tag_date = []
|
186
|
+
pairs.each do |pair|
|
187
|
+
tag = pair.split('...').last
|
188
|
+
dates.each do |line|
|
189
|
+
# regular tag, or tag on master.
|
190
|
+
if line.include?(tag + ')') || line.include?(tag + ',')
|
191
|
+
tag_date.push tag + ' ' + line.match(/\d{4}-\d{2}-\d{2}/)[0]
|
192
|
+
break
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
pairs.each_index do |a|
|
198
|
+
data =`git log --pretty=oneline #{pairs[a]}`
|
199
|
+
new_data = ''
|
200
|
+
data.split("\n").each do |line|
|
201
|
+
hex = line.match(/[a-zA-Z0-9]+/)[0]
|
202
|
+
# use first 7 chars to match GitHub
|
203
|
+
comment = line.gsub(hex, '').strip
|
204
|
+
next if comment == 'Update release notes'
|
205
|
+
new_data += "- [#{hex[0...7]}](https://github.com/#{gh_name}/commit/#{hex}) #{comment}\n"
|
206
|
+
end
|
207
|
+
data = new_data + "\n"
|
208
|
+
|
209
|
+
# last pair is the released version.
|
210
|
+
notes += "#### #{tag_date[a]}\n\n" + data + "\n"
|
211
|
+
end
|
212
|
+
|
213
|
+
File.open('release_notes.md', 'w') { |f| f.write notes.to_s.strip }
|
214
|
+
end
|
data/design_rationale.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# Specs: # Equivalent Unit Tests:
|
2
|
+
###############################################################################
|
3
|
+
describe Thingy do # class TestThingy < Minitest::Test
|
4
|
+
before do # def setup
|
5
|
+
do_some_setup # super
|
6
|
+
end # do_some_setup
|
7
|
+
# end
|
8
|
+
it "should do the first thing" do #
|
9
|
+
1.must_equal 1 # def test_first_thing
|
10
|
+
end # assert_equal 1, 1
|
11
|
+
# end
|
12
|
+
describe SubThingy do # end
|
13
|
+
before do #
|
14
|
+
do_more_setup # class TestSubThingy < TestThingy
|
15
|
+
end # def setup
|
16
|
+
# super
|
17
|
+
it "should do the second thing" do # do_more_setup
|
18
|
+
2.must_equal 2 # end
|
19
|
+
end #
|
20
|
+
end # def test_second_thing
|
21
|
+
end # assert_equal 2, 2
|
22
|
+
# end
|
23
|
+
# end
|
24
|
+
###############################################################################
|
25
|
+
# runs 2 specs # runs 3 tests
|
26
|
+
###############################################################################
|
27
|
+
# The specs generate:
|
28
|
+
|
29
|
+
class ThingySpec < Minitest::Spec
|
30
|
+
def setup
|
31
|
+
super
|
32
|
+
do_some_setup
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_should_do_the_first_thing
|
36
|
+
assert_equal 1, 1
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class SubThingySpec < ThingySpec
|
41
|
+
def setup
|
42
|
+
super
|
43
|
+
do_more_setup
|
44
|
+
end
|
45
|
+
|
46
|
+
# because only setup/teardown is inherited, not specs
|
47
|
+
remove_method :test_should_do_the_first_thing
|
48
|
+
|
49
|
+
def test_should_do_the_second_thing
|
50
|
+
assert_equal 2, 2
|
51
|
+
end
|
52
|
+
end
|
data/lib/hoe/minitest.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# :stopdoc:
|
2
|
+
|
3
|
+
class Hoe
|
4
|
+
end
|
5
|
+
|
6
|
+
module Hoe::Minitest
|
7
|
+
def initialize_minitest
|
8
|
+
dir = "../../minitest/dev/lib"
|
9
|
+
Hoe.add_include_dirs dir if File.directory? dir
|
10
|
+
|
11
|
+
gem "minitest"
|
12
|
+
require "minitest"
|
13
|
+
version = Minitest::VERSION.split(/\./).first(2).join(".")
|
14
|
+
|
15
|
+
dependency "minitest", "~> #{version}", :development unless
|
16
|
+
self.name == "minitest" or ENV["MT_NO_ISOLATE"]
|
17
|
+
end
|
18
|
+
|
19
|
+
def define_minitest_tasks
|
20
|
+
self.testlib = :minitest
|
21
|
+
|
22
|
+
# make sure we use the gemmed minitest on 1.9
|
23
|
+
self.test_prelude = 'gem "minitest"' unless
|
24
|
+
self.name == "minitest" or ENV["MT_NO_ISOLATE"]
|
25
|
+
end
|
26
|
+
end
|