quarry 0.5.0 → 0.5.2
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.
- data/CHANGES +33 -1
- data/MANIFEST +32 -27
- data/README +41 -35
- data/RELEASE +6 -5
- data/TODO +9 -0
- data/VERSION +1 -1
- data/bin/quarry +25 -11
- data/bin/{ruby-xacto → quarry-extract} +0 -0
- data/lib/quarry/assertion.rb +1 -5
- data/lib/quarry/document.rb +2 -2
- data/lib/quarry/grammar/assert.rb +14 -4
- data/lib/quarry/grammar/legacy/assert.rb +33 -22
- data/lib/quarry/grammar/should.rb +2 -2
- data/lib/quarry/markup.rb +32 -6
- data/lib/quarry/markup/after.rb +28 -0
- data/lib/quarry/markup/before.rb +28 -0
- data/lib/quarry/markup/comment.rb +56 -0
- data/lib/quarry/markup/header.rb +42 -0
- data/lib/quarry/markup/macro.rb +53 -0
- data/lib/quarry/markup/step.rb +43 -47
- data/lib/quarry/markup/table.rb +89 -0
- data/lib/quarry/monitor.rb +4 -0
- data/lib/quarry/reporter.rb +25 -3
- data/lib/quarry/reporter/dotprogress.rb +5 -3
- data/lib/quarry/reporter/summary.rb +7 -7
- data/lib/quarry/reporter/verbatim.rb +24 -18
- data/lib/quarry/runner.rb +37 -18
- data/lib/quarry/runner/context.rb +1 -1
- data/spec/{stub.rd → 03_stub.rd} +0 -0
- data/spec/{mock.rd → 04_mock.rd} +0 -0
- metadata +14 -8
- data/spec/basic.rd +0 -18
- data/spec/complex.rd +0 -48
data/CHANGES
CHANGED
@@ -1,6 +1,35 @@
|
|
1
|
+
== 0.5.2 / 2008-11-28
|
2
|
+
|
3
|
+
* 21 Other Enhancements
|
4
|
+
|
5
|
+
* renamed specs with enumerations (#ab5cd7c746d934993dd54d72e9e217dd0777a7f5)
|
6
|
+
* better output on error output (#b1c56a4e7df4ca6e6b772a1f6b8e220dc4c812be)
|
7
|
+
* sort specs when documenting (#e587777eed633106fd075c4f1cee141e8fdd714c)
|
8
|
+
* bin/quarry, separated verbatim from verbose (#ea4fcf3539f98164ae18fd00136595ae9fc775b4)
|
9
|
+
* continued work on website (#eaaac37d2ece34145abae377b9fcae44025d08ab)
|
10
|
+
* fixed should grammar (#168fe5965911a442c7930006c6b8faf849c613fe)
|
11
|
+
* updated README (#32f237b10ef44c2e065fc45844201ac074199f03)
|
12
|
+
* added #p to monitor (#a42cc437348b4d62f26939bd357761612ed28487)
|
13
|
+
* work on tabular (#b6d3f4e687df4eedd29a4ae9871c67f35ee13b62)
|
14
|
+
* adjusted header css for website (#fa5037f70a830c6513121ab69bb81970ab4c869e)
|
15
|
+
* Merge: fa5037f... b6d3f4e...
|
16
|
+
Merge branch 'master' of gitosis@rubyforge.org:quarry (#381903a9f6523bcd466242810da88208f8296de9)
|
17
|
+
* work on table macros, improved markup parsing (#aa9e0b4f4a99a7ee0cb7313ed8593285919e6350)
|
18
|
+
* Merge: 381903a... aa9e0b4...
|
19
|
+
Merge branch 'master' of gitosis@rubyforge.org:quarry (#d12faecf82b46423234ea873d64d3a1a983be30e)
|
20
|
+
* made markup object reposible for running their own code (#85adcfac7fc7b901db27cce659f7a24d192bc7a1)
|
21
|
+
* made assert method compatible w/ old school (#5928ee8ad0bbc8178254b5043b09d64a5e09b070)
|
22
|
+
* moved sample spec's to demo/ (#759fd887741f892752ade8776a9c05c7fdbdc036)
|
23
|
+
* improved reporter for better tabular output (#8fdb7eb6c09b0cec16f333fca004594bea4eb162)
|
24
|
+
* prepare release of 0.5.1 (#eb342d8c2a66ec59d9aa1c9b6de76b6b9e9337fb)
|
25
|
+
* added TODO and some comments to reporter.rb (#a225aef3ac5947d4fcc5b77a4cb491b34a3fea55)
|
26
|
+
* markup now tracks before/after instead of runner (#42205099bbaa5b90f105741a0f7b05737426a058)
|
27
|
+
* --script mode now works (#1e9e5919b62da86db2c5c4a15a1ebdb59e75f5d3)
|
28
|
+
|
29
|
+
|
1
30
|
== 0.5.0 / 2008-11-19
|
2
31
|
|
3
|
-
*
|
32
|
+
* 15 Other Enhancements
|
4
33
|
|
5
34
|
* imporved quarry doc tool (#36ce74b4f694b984bc9addc22eb74d6ecbb503e5)
|
6
35
|
* bin/quarry, added loadpath option (#6ba04ef83777d64192c9c62c9060d8fa37aad933)
|
@@ -14,6 +43,9 @@
|
|
14
43
|
* clean-up some code (#35b47d0254ccaf7594d5c1db0c5a88021ff8a795)
|
15
44
|
* bin/quarry, fixed references (#8c2b5094b5b647415dcbd31212b1270ca317e1ce)
|
16
45
|
* fixed old Spec namespace and backtrace argument to Assertion (#6d6deaad38c3abb5dce164067970bee82412c93e)
|
46
|
+
* prep for 0.5.0 (#b4f808d65d766f91f04fa36b7ee3274b6868af3e)
|
47
|
+
* update spec.js (#f79443ef0bb4b84302c7104ff69e7ad18cfd7a1d)
|
48
|
+
* renamed ruby-xacto to quarry-extract (#9fe0dafcef9d73baef4b719687e3e908aeb7789a)
|
17
49
|
|
18
50
|
|
19
51
|
== 0.4.0 / 2008-11-15
|
data/MANIFEST
CHANGED
@@ -1,54 +1,59 @@
|
|
1
|
+
bin
|
2
|
+
lib
|
3
|
+
meta
|
1
4
|
spec
|
2
|
-
spec/complex.rd
|
3
|
-
spec/mock.rd
|
4
|
-
spec/basic.rd
|
5
|
-
spec/stub.rd
|
6
5
|
MANIFEST
|
7
6
|
CHANGES
|
8
7
|
RELEASE
|
8
|
+
TODO
|
9
9
|
README
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
meta/authors
|
16
|
-
meta/requires
|
17
|
-
lib
|
10
|
+
VERSION
|
11
|
+
COPYING
|
12
|
+
bin/quarry
|
13
|
+
bin/quarry-doc
|
14
|
+
bin/quarry-extract
|
18
15
|
lib/quarry
|
16
|
+
lib/quarry.rb
|
19
17
|
lib/quarry/probe.rb
|
20
18
|
lib/quarry/document
|
21
|
-
lib/quarry/document/template.rhtml
|
22
19
|
lib/quarry/grammar.rb
|
23
20
|
lib/quarry/config.rb
|
24
21
|
lib/quarry/runner.rb
|
25
22
|
lib/quarry/runner
|
26
|
-
lib/quarry/runner/context.rb
|
27
23
|
lib/quarry/stub.rb
|
28
24
|
lib/quarry/mock.rb
|
29
25
|
lib/quarry/extract.rb
|
30
26
|
lib/quarry/markup.rb
|
31
27
|
lib/quarry/reporter
|
32
|
-
lib/quarry/reporter/verbatim.rb
|
33
|
-
lib/quarry/reporter/dotprogress.rb
|
34
|
-
lib/quarry/reporter/summary.rb
|
35
28
|
lib/quarry/monitor.rb
|
36
29
|
lib/quarry/reporter.rb
|
37
30
|
lib/quarry/expectation.rb
|
38
31
|
lib/quarry/document.rb
|
39
32
|
lib/quarry/grammar
|
33
|
+
lib/quarry/markup
|
34
|
+
lib/quarry/assertion.rb
|
35
|
+
lib/quarry/document/template.rhtml
|
36
|
+
lib/quarry/runner/context.rb
|
37
|
+
lib/quarry/reporter/verbatim.rb
|
38
|
+
lib/quarry/reporter/dotprogress.rb
|
39
|
+
lib/quarry/reporter/summary.rb
|
40
40
|
lib/quarry/grammar/expect.rb
|
41
41
|
lib/quarry/grammar/assert.rb
|
42
42
|
lib/quarry/grammar/legacy
|
43
|
-
lib/quarry/grammar/legacy/assert.rb
|
44
43
|
lib/quarry/grammar/should.rb
|
45
|
-
lib/quarry/
|
44
|
+
lib/quarry/grammar/legacy/assert.rb
|
45
|
+
lib/quarry/markup/macro.rb
|
46
46
|
lib/quarry/markup/step.rb
|
47
|
-
lib/quarry/
|
48
|
-
lib/quarry.rb
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
47
|
+
lib/quarry/markup/before.rb
|
48
|
+
lib/quarry/markup/header.rb
|
49
|
+
lib/quarry/markup/after.rb
|
50
|
+
lib/quarry/markup/table.rb
|
51
|
+
lib/quarry/markup/comment.rb
|
52
|
+
meta/created
|
53
|
+
meta/homepage
|
54
|
+
meta/summary
|
55
|
+
meta/abstract
|
56
|
+
meta/authors
|
57
|
+
meta/requires
|
58
|
+
spec/04_mock.rd
|
59
|
+
spec/03_stub.rd
|
data/README
CHANGED
@@ -15,71 +15,77 @@ useful QA tools.
|
|
15
15
|
|
16
16
|
=== Specifications
|
17
17
|
|
18
|
-
Quarry's
|
19
|
-
Ruby's Execption system to catch Assertions which are defined
|
20
|
-
|
21
|
-
|
22
|
-
require 'quarry/assertion'
|
18
|
+
Quarry's BDD/TDD system is uniqe in a few ways. First it utilizes
|
19
|
+
Ruby's Execption system to catch Assertions which are defined via
|
20
|
+
assertion <i>functors</i>. Eg.
|
23
21
|
|
24
22
|
4.assert == 5
|
25
23
|
|
26
24
|
Because 4 != 5, this expression will raise an Assertion exception.
|
27
|
-
Quarry's Specification Runner class is thus just a means of
|
28
|
-
|
25
|
+
Quarry's Specification Runner class is thus just a means of running
|
26
|
+
and capturing these assertions.
|
27
|
+
|
28
|
+
While we used TDD teminology in the above example, Quarry supports
|
29
|
+
a range of momenclature to suit the preferences of TDD vs. BDD
|
30
|
+
developers. The abot could just as well been written as:
|
31
|
+
|
32
|
+
4.should == 5
|
33
|
+
|
34
|
+
or
|
35
|
+
|
36
|
+
4.expect == 5
|
37
|
+
|
38
|
+
These are effecitvely the same. For the most part the different terms
|
39
|
+
do exactly the same thing. Somtimes though they differ to conform with
|
40
|
+
the TDD vs. BDD prespective they intend to support.
|
29
41
|
|
30
|
-
Quarry's Specifications themselves are simple text files
|
42
|
+
Quarry's Specifications themselves are simple text files --a practice
|
31
43
|
of literal programming.
|
32
44
|
|
33
45
|
Example Specification
|
34
46
|
=====================
|
47
|
+
|
35
48
|
Shows that the number 5 does not equal 4.
|
36
49
|
|
37
|
-
5.
|
50
|
+
5.should! == 4
|
38
51
|
|
39
52
|
But in fact equals 5.
|
40
53
|
|
41
|
-
5.
|
42
|
-
|
43
|
-
QED.
|
54
|
+
5.should == 5
|
44
55
|
|
45
|
-
If we run this specification in verbatim mode the output would identical
|
46
|
-
(assuming we did not make a
|
47
|
-
|
48
|
-
detaling each.
|
56
|
+
If we run this specification in verbatim mode the output would be identical
|
57
|
+
(assuming we did not make a typo and the assertions passed). If there were
|
58
|
+
errors or failures, we would see information detaling each.
|
49
59
|
|
50
|
-
As you can see
|
51
|
-
format
|
60
|
+
As you can see, we used Markdown for this spcecification. Almost any
|
61
|
+
format can be used. The only neccesary distinction is that desciption text be
|
52
62
|
align to the left margin and all specification code be indented. Quarry also
|
53
|
-
recognized headers, currently Markdown and RDoc style headers
|
54
|
-
|
63
|
+
recognized headers, currently Markdown and RDoc style headers, which covers
|
64
|
+
most markup foramts in common use today. While strictly speaking Qaurry
|
65
|
+
does not need to recognize headers, it does improve console output a bit
|
66
|
+
if it does.
|
55
67
|
|
56
|
-
|
57
|
-
|
58
|
-
|
68
|
+
Give this design some though. It should become clear that this approach if
|
69
|
+
especially fruitful in that it allows documentation and specification to
|
70
|
+
seemlessly merge.
|
59
71
|
|
60
72
|
|
61
|
-
=== Stubs
|
73
|
+
=== Stubs, Mocks and Spies
|
62
74
|
|
63
|
-
Quarry provides a flexible stubbing facility.
|
75
|
+
Quarry provides a flexible stubbing and mocking facility.
|
64
76
|
|
65
77
|
For now see RDoc API.
|
66
78
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
MethodProbe (aka the Duck Hunter) can dip-down into a method and
|
71
|
-
provide a read-out how it functions --known as a <i>method signiture</i>.
|
72
|
-
MethodProbe is somewhat expiremental becuase it is runtime bound, so proper
|
79
|
+
The Spy/Probe (aka the Duck Hunter) can dip-down into a method and
|
80
|
+
provide a read-out how it functions --known as a <i>method signature</i>.
|
81
|
+
Probe is somewhat expiremental becuase it is runtime bound, so proper
|
73
82
|
execution can not be 100% guarenteed. It can miss some parts of a method
|
74
|
-
due to conditional branching (a probe can
|
83
|
+
due to conditional branching (a probe can't pretend to be false) and,
|
75
84
|
albiet rare, it can also get stuck in an infinite loop a la the
|
76
85
|
Halting Problem. Even so, it can be used effectively under controlled
|
77
86
|
situations if used with care.
|
78
87
|
|
79
88
|
|
80
|
-
=== More to come ....
|
81
|
-
|
82
|
-
|
83
89
|
== Copying
|
84
90
|
|
85
91
|
Copyright (c) 2007, 2008 Tiger Ops / Thomas Sawyer
|
data/RELEASE
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
This
|
2
|
-
|
1
|
+
This release improves the Markup class structure allowing for
|
2
|
+
tabular steps and script output.
|
3
3
|
|
4
4
|
|
5
|
-
### 0.5.
|
5
|
+
### 0.5.2 / 2008-11-28
|
6
6
|
|
7
|
-
* Major Enhancements
|
7
|
+
* 2 Major Enhancements
|
8
8
|
|
9
|
-
*
|
9
|
+
* Markup tracks before and after macros.
|
10
|
+
* Script output using --script option.
|
10
11
|
|
data/TODO
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
= TODO List
|
2
|
+
|
3
|
+
* Reporting could still use some improvement. The idea
|
4
|
+
was to pass the Step object to the step report methods,
|
5
|
+
but this is a bit of a problem for tabular output, since
|
6
|
+
we don't wnat to print the same code over and over.
|
7
|
+
So right now it uses a Faux Step. Not sure that's the
|
8
|
+
best way to do it.
|
9
|
+
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
quarry 0.5.
|
1
|
+
quarry 0.5.2 beta (2008-11-28)
|
data/bin/quarry
CHANGED
@@ -22,9 +22,11 @@ module Quarry
|
|
22
22
|
@opts ||= GetoptLong.new(
|
23
23
|
[ '--version', GetoptLong::NO_ARGUMENT ],
|
24
24
|
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
|
25
|
-
[ '--debug', '-
|
26
|
-
[ '--verbose', '-
|
25
|
+
[ '--debug', '-D', GetoptLong::NO_ARGUMENT ],
|
26
|
+
[ '--verbose', '-V', GetoptLong::NO_ARGUMENT ],
|
27
|
+
[ '--verbatim', '-v', GetoptLong::NO_ARGUMENT ],
|
27
28
|
[ '--summary', '-s', GetoptLong::NO_ARGUMENT ],
|
29
|
+
[ '--script', GetoptLong::NO_ARGUMENT ],
|
28
30
|
[ '--loadpath', '-I', GetoptLong::REQUIRED_ARGUMENT ]
|
29
31
|
)
|
30
32
|
end
|
@@ -39,9 +41,13 @@ module Quarry
|
|
39
41
|
when '--debug'
|
40
42
|
$DEBUG = true
|
41
43
|
when '--verbose'
|
42
|
-
|
44
|
+
$VERBOSE = true
|
45
|
+
when '--verbatim'
|
46
|
+
@reporter = :verbatim
|
43
47
|
when '--summary'
|
44
48
|
@reporter = :summary
|
49
|
+
when '--script'
|
50
|
+
@reporter = :script # psuedo-reporter
|
45
51
|
when '--loadpath'
|
46
52
|
arg.split(/[:;]/).each{|dir| $LOAD_PATH.unshift(dir)}
|
47
53
|
end
|
@@ -83,7 +89,7 @@ module Quarry
|
|
83
89
|
#
|
84
90
|
def output
|
85
91
|
case reporter
|
86
|
-
when :
|
92
|
+
when :verbatim
|
87
93
|
Quarry::Reporter::Verbatim.new
|
88
94
|
when :summary
|
89
95
|
Quarry::Reporter::Summary.new
|
@@ -100,18 +106,26 @@ module Quarry
|
|
100
106
|
def execute
|
101
107
|
parse_options
|
102
108
|
load_rc
|
103
|
-
|
109
|
+
case reporter
|
110
|
+
when :script
|
111
|
+
specs.each do |spec|
|
112
|
+
puts spec.to_script
|
113
|
+
end
|
114
|
+
else
|
115
|
+
runner.check
|
116
|
+
end
|
104
117
|
end
|
105
118
|
|
106
119
|
HELP = <<-END
|
107
|
-
quarry [--options] [
|
120
|
+
quarry [--options] [spec/tests...]
|
108
121
|
|
109
122
|
Options:
|
110
|
-
-v --
|
111
|
-
-s --summary
|
112
|
-
|
113
|
-
-
|
114
|
-
|
123
|
+
-v --verbatim use verbatim reporter
|
124
|
+
-s --summary use summary reporter
|
125
|
+
-V --verbose extra verbose output
|
126
|
+
-D --debug spec/tests will exit on error
|
127
|
+
-h --help show this help information
|
128
|
+
--version show quarry version
|
115
129
|
END
|
116
130
|
|
117
131
|
end
|
File without changes
|
data/lib/quarry/assertion.rb
CHANGED
data/lib/quarry/document.rb
CHANGED
@@ -42,12 +42,12 @@ module Quarry
|
|
42
42
|
|
43
43
|
# Generate specification document.
|
44
44
|
def generate
|
45
|
+
text = ''
|
45
46
|
files = []
|
46
47
|
paths.each do |path|
|
47
48
|
files.concat(Dir.glob(path).select{ |f| File.file?(f) })
|
48
49
|
end
|
49
|
-
|
50
|
-
text = ''
|
50
|
+
files.sort!
|
51
51
|
files.each do |file|
|
52
52
|
puts file unless quiet?
|
53
53
|
case ext = File.extname(file)
|
@@ -13,8 +13,13 @@ module Quarry
|
|
13
13
|
#
|
14
14
|
# 4.assert == 3
|
15
15
|
#
|
16
|
-
def assert
|
17
|
-
|
16
|
+
def assert(test=nil, msg=nil)
|
17
|
+
if test
|
18
|
+
msg = "failed assertion (no message given)" unless msg
|
19
|
+
raise Assertion.new(msg, caller) unless test
|
20
|
+
else
|
21
|
+
return Expectation.new(self, :backtrace=>caller)
|
22
|
+
end
|
18
23
|
end
|
19
24
|
|
20
25
|
# Assert not an operational relationship.
|
@@ -26,8 +31,13 @@ module Quarry
|
|
26
31
|
# if Ruby would allow +!=+ to be define as a method,
|
27
32
|
# or at least +!+ as a unary method.
|
28
33
|
#
|
29
|
-
def assert!
|
30
|
-
|
34
|
+
def assert!(test=nil, msg=nil)
|
35
|
+
if test
|
36
|
+
msg = "failed assertion (no message given)" unless msg
|
37
|
+
raise Assertion.new(msg, caller) if test
|
38
|
+
else
|
39
|
+
return Expectation.new(self, :negate=>true, :backtrace=>caller)
|
40
|
+
end
|
31
41
|
end
|
32
42
|
|
33
43
|
# Same as #assert!.
|
@@ -16,16 +16,26 @@ module Quarry
|
|
16
16
|
#
|
17
17
|
module Assertions
|
18
18
|
|
19
|
+
# Private method upon which all of the legacy assertions are based
|
20
|
+
# (except for #assert itself).
|
21
|
+
#
|
22
|
+
def __assert__(test, msg=nil)
|
23
|
+
msg = "failed assertion (no message given)" unless msg
|
24
|
+
raise Assertion.new(msg, caller[1..-1]) unless test
|
25
|
+
end
|
26
|
+
|
27
|
+
private :__assert__
|
28
|
+
|
19
29
|
# The assertion upon which all other assertions are based.
|
20
30
|
#
|
21
31
|
# assert [1, 2].include?(5)
|
22
32
|
#
|
23
33
|
def assert(test=nil, msg=nil)
|
24
34
|
if test
|
25
|
-
msg = "failed assertion (no message given)"
|
26
|
-
raise
|
35
|
+
msg = "failed assertion (no message given)" unless msg
|
36
|
+
raise Assertion.new(msg, caller) unless test
|
27
37
|
else
|
28
|
-
Expectation.new(:
|
38
|
+
Expectation.new(self, :backtrace=>caller)
|
29
39
|
end
|
30
40
|
end
|
31
41
|
|
@@ -38,7 +48,7 @@ module Quarry
|
|
38
48
|
def assert_block(msg=nil) # :yields:
|
39
49
|
test = ! yield
|
40
50
|
msg = "assertion failed" unless msg
|
41
|
-
|
51
|
+
__assert__(test, msg)
|
42
52
|
end
|
43
53
|
|
44
54
|
# Passes if expected == +actual.
|
@@ -52,7 +62,7 @@ module Quarry
|
|
52
62
|
def assert_equal(exp, act, msg=nil)
|
53
63
|
test = (exp == act)
|
54
64
|
msg = "Expected #{act.inspect} to be equal to #{exp.inspect}" unless msg
|
55
|
-
|
65
|
+
__assert__(test, msg)
|
56
66
|
end
|
57
67
|
|
58
68
|
# Passes if expected_float and actual_float are equal within delta tolerance.
|
@@ -62,7 +72,7 @@ module Quarry
|
|
62
72
|
def assert_in_delta(exp, act, delta, msg=nil)
|
63
73
|
test = (exp.to_f - act.to_f).abs <= delta.to_f
|
64
74
|
msg = "Expected #{exp} to be within #{delta} of #{act}" unless msg
|
65
|
-
|
75
|
+
__assert__(test, msg)
|
66
76
|
end
|
67
77
|
|
68
78
|
# Passes if object .instance_of? klass
|
@@ -72,7 +82,7 @@ module Quarry
|
|
72
82
|
def assert_instance_of(cls, obj, msg=nil)
|
73
83
|
test = (cls === obj)
|
74
84
|
msg = "Expected #{obj} to be a #{cls}" unless msg
|
75
|
-
|
85
|
+
__assert__(test, msg)
|
76
86
|
end
|
77
87
|
|
78
88
|
# Passes if object .kind_of? klass
|
@@ -82,7 +92,7 @@ module Quarry
|
|
82
92
|
def assert_kind_of(cls, obj, msg=nil)
|
83
93
|
test = obj.kind_of?(cls)
|
84
94
|
msg = "Expected #{obj.inspect} to be a kind of #{cls}" unless msg
|
85
|
-
|
95
|
+
__assert__(test, msg)
|
86
96
|
end
|
87
97
|
|
88
98
|
# Passes if string =~ pattern.
|
@@ -92,7 +102,7 @@ module Quarry
|
|
92
102
|
def assert_match(exp, act, msg=nil)
|
93
103
|
test = (act =~ exp)
|
94
104
|
msg = "Expected #{act.inspect} to match #{exp.inspect}" unless msg
|
95
|
-
|
105
|
+
__assert__(test, msg)
|
96
106
|
end
|
97
107
|
|
98
108
|
# Passes if object is nil.
|
@@ -102,7 +112,7 @@ module Quarry
|
|
102
112
|
def assert_nil(obj, msg=nil)
|
103
113
|
test = obj.nil?
|
104
114
|
msg = "Expected #{obj.inspect} to be nil" unless msg
|
105
|
-
|
115
|
+
__assert__(test, msg)
|
106
116
|
end
|
107
117
|
|
108
118
|
# Passes if regexp !~ string
|
@@ -112,7 +122,7 @@ module Quarry
|
|
112
122
|
def assert_no_match(exp, act, msg=nil)
|
113
123
|
test = (act !~ exp)
|
114
124
|
msg = "Expected #{act.inspect} to match #{exp.inspect}" unless msg
|
115
|
-
|
125
|
+
__assert__(test, msg)
|
116
126
|
end
|
117
127
|
|
118
128
|
# Passes if expected != actual
|
@@ -122,7 +132,7 @@ module Quarry
|
|
122
132
|
def assert_not_equal(exp, act, msg=nil)
|
123
133
|
test = (exp != act)
|
124
134
|
msg = "Expected #{act.inspect} to not be equal to #{exp.inspect}" unless msg
|
125
|
-
|
135
|
+
__assert__(test, msg)
|
126
136
|
end
|
127
137
|
|
128
138
|
# Passes if ! object .nil?
|
@@ -132,7 +142,7 @@ module Quarry
|
|
132
142
|
def assert_not_nil(obj, msg=nil)
|
133
143
|
test = ! obj.nil?
|
134
144
|
msg = "Expected #{obj.inspect} to not be nil" unless msg
|
135
|
-
|
145
|
+
__assert__(test, msg)
|
136
146
|
end
|
137
147
|
|
138
148
|
# Passes if ! actual .equal? expected
|
@@ -142,7 +152,7 @@ module Quarry
|
|
142
152
|
def assert_not_same(exp, act, msg=nil)
|
143
153
|
test = ! exp.equal?(act)
|
144
154
|
msg = "Expected #{act.inspect} to not be the same as #{exp.inspect}" unless msg
|
145
|
-
|
155
|
+
__assert__(test, msg)
|
146
156
|
end
|
147
157
|
|
148
158
|
# Compares the +object1+ with +object2+ using operator.
|
@@ -154,7 +164,7 @@ module Quarry
|
|
154
164
|
def assert_operator(o1, op, o2, msg="")
|
155
165
|
test = o1.__send__(op, o2)
|
156
166
|
msg = "Expected #{o1}.#{op}(#{o2}) to be true" unless msg
|
157
|
-
|
167
|
+
__assert__(test, msg)
|
158
168
|
end
|
159
169
|
|
160
170
|
# Passes if the block raises one of the given exceptions.
|
@@ -168,14 +178,15 @@ module Quarry
|
|
168
178
|
begin
|
169
179
|
yield
|
170
180
|
msg = "Expected #{exp} to be raised" unless msg
|
171
|
-
|
181
|
+
__assert__(false, msg)
|
172
182
|
rescue Exception => e
|
173
183
|
test = (exp === e)
|
174
184
|
msg = "Expected #{exp} to be raised, but got #{e.class}" unless msg
|
175
|
-
|
185
|
+
__assert__(test, msg)
|
176
186
|
return e
|
177
187
|
end
|
178
188
|
end
|
189
|
+
|
179
190
|
alias_method :assert_raise, :assert_raises
|
180
191
|
|
181
192
|
# Provides a way to assert that a procedure
|
@@ -201,7 +212,7 @@ module Quarry
|
|
201
212
|
#flip = (Symbol === obj) && ! (Symbol === meth) # HACK for specs
|
202
213
|
#obj, meth = meth, obj if flip
|
203
214
|
test = obj.respond_to?(meth)
|
204
|
-
|
215
|
+
__assert__(test, msg)
|
205
216
|
end
|
206
217
|
|
207
218
|
# Passes if +actual+ .equal? +expected+ (i.e. they are the same instance).
|
@@ -212,7 +223,7 @@ module Quarry
|
|
212
223
|
def assert_same(exp, act, msg=nil)
|
213
224
|
msg = "Expected #{act.inspect} to be the same as #{exp.inspect}" unless msg
|
214
225
|
test = exp.equal?(act)
|
215
|
-
|
226
|
+
__assert__(test, msg)
|
216
227
|
end
|
217
228
|
|
218
229
|
# Passes if the method send returns a true value.
|
@@ -230,7 +241,7 @@ module Quarry
|
|
230
241
|
r, m, *args = *send_array
|
231
242
|
test = r.__send__(m, *args)
|
232
243
|
msg = "Expected #{r}.#{m}(*#{args.inspect}) to return true" unless msg
|
233
|
-
|
244
|
+
__assert__(test, msg)
|
234
245
|
end
|
235
246
|
|
236
247
|
# Passes if the block throws expected_symbol
|
@@ -252,7 +263,7 @@ module Quarry
|
|
252
263
|
end
|
253
264
|
test = false
|
254
265
|
end
|
255
|
-
|
266
|
+
__assert__(test, msg)
|
256
267
|
end
|
257
268
|
|
258
269
|
# Flunk always fails.
|
@@ -260,7 +271,7 @@ module Quarry
|
|
260
271
|
# flunk 'Not done testing yet.'
|
261
272
|
#
|
262
273
|
def flunk(msg=nil)
|
263
|
-
|
274
|
+
__assert__(false, msg)
|
264
275
|
end
|
265
276
|
|
266
277
|
end #module Assertions
|