Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 73 lines (55 sloc) 2.02 kB
17bc421 @zenspider Branched miniunit into minitest w/o test/unit compatibility
zenspider authored
1 # -*- ruby -*-
2
e8d8c2a @zenspider For "fun", I defined a rubocop config that best represents "Seattle S…
zenspider authored
3 require "rubygems"
4 require "hoe"
17bc421 @zenspider Branched miniunit into minitest w/o test/unit compatibility
zenspider authored
5
8d0f55d @zenspider + Updated rakefile for new hoe capabilities.
zenspider authored
6 Hoe.plugin :seattlerb
ed3107e @zenspider Renamed README.txt to README.rdoc to quell all the github-centric whi…
zenspider authored
7 Hoe.plugin :rdoc
17bc421 @zenspider Branched miniunit into minitest w/o test/unit compatibility
zenspider authored
8
e8d8c2a @zenspider For "fun", I defined a rubocop config that best represents "Seattle S…
zenspider authored
9 Hoe.spec "minitest" do
10 developer "Ryan Davis", "ryand-ruby@zenspider.com"
60f6594 @zenspider Finished rename for minitest/...
zenspider authored
11
92b5dea @zenspider prepped for release
zenspider authored
12 license "MIT"
13
78454b8 @zenspider + Added examples to readme (Mike Dalessio)
zenspider authored
14 self.testlib = :minitest
17bc421 @zenspider Branched miniunit into minitest w/o test/unit compatibility
zenspider authored
15 end
16
3225d27 @zenspider Moved spec audit code to the rake task 'specs'.
zenspider authored
17 desc "Find missing expectations"
18 task :specs do
19 $:.unshift "lib"
20 require "minitest/unit"
21 require "minitest/spec"
22
23 pos_prefix, neg_prefix = "must", "wont"
24 skip_re = /^(must|wont)$|wont_(throw)|must_(block|not?_|nothing|raise$)/x
25 dont_flip_re = /(must|wont)_(include|respond_to)/
26
27 map = {
28 /(must_throw)s/ => '\1',
e8d8c2a @zenspider For "fun", I defined a rubocop config that best represents "Seattle S…
zenspider authored
29 /(?!not)_same/ => "_be_same_as",
30 /_in_/ => "_be_within_",
31 /_operator/ => "_be",
32 /_includes/ => "_include",
3225d27 @zenspider Moved spec audit code to the rake task 'specs'.
zenspider authored
33 /(must|wont)_(.*_of|nil|silent|empty)/ => '\1_be_\2',
e8d8c2a @zenspider For "fun", I defined a rubocop config that best represents "Seattle S…
zenspider authored
34 /must_raises/ => "must_raise",
3225d27 @zenspider Moved spec audit code to the rake task 'specs'.
zenspider authored
35 }
36
8546e45 @zenspider - DOH! Fixed the rest of the new casing on Minitest. (spattael)
zenspider authored
37 expectations = Minitest::Expectations.public_instance_methods.map(&:to_s)
38 assertions = Minitest::Assertions.public_instance_methods.map(&:to_s)
3225d27 @zenspider Moved spec audit code to the rake task 'specs'.
zenspider authored
39
40 assertions.sort.each do |assertion|
41 expectation = case assertion
42 when /^assert/ then
43 assertion.sub(/^assert/, pos_prefix.to_s)
44 when /^refute/ then
45 assertion.sub(/^refute/, neg_prefix.to_s)
46 end
47
48 next unless expectation
49 next if expectation =~ skip_re
50
51 regexp, replacement = map.find { |re, _| expectation =~ re }
52 expectation.sub! regexp, replacement if replacement
53
54 next if expectations.include? expectation
55
56 args = [assertion, expectation].map(&:to_sym).map(&:inspect)
57 args << :reverse if expectation =~ dont_flip_re
58
59 puts
60 puts "##"
61 puts "# :method: #{expectation}"
8546e45 @zenspider - DOH! Fixed the rest of the new casing on Minitest. (spattael)
zenspider authored
62 puts "# See Minitest::Assertions##{assertion}"
3225d27 @zenspider Moved spec audit code to the rake task 'specs'.
zenspider authored
63 puts
64 puts "infect_an_assertion #{args.join ", "}"
65 end
66 end
67
de0f486 @zenspider prepped for release
zenspider authored
68 task :bugs do
69 sh "for f in bug*.rb ; do echo $f; echo; #{Gem.ruby} -Ilib $f && rm $f ; done"
70 end
71
17bc421 @zenspider Branched miniunit into minitest w/o test/unit compatibility
zenspider authored
72 # vim: syntax=Ruby
Something went wrong with that request. Please try again.