quarry 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +22 -1
- data/MANIFEST +30 -339
- data/RELEASE +2 -4
- data/VERSION +1 -1
- data/bin/quarry +14 -10
- data/bin/quarry-doc +2 -2
- data/lib/quarry/assertion.rb +27 -0
- data/lib/quarry/{spec/config.rb → config.rb} +0 -0
- data/lib/quarry/document/template.rhtml +239 -0
- data/lib/quarry/document.rb +126 -0
- data/lib/quarry/expectation.rb +60 -0
- data/lib/quarry/extract.rb +2 -0
- data/lib/quarry/grammar/assert.rb +48 -0
- data/lib/quarry/grammar/expect.rb +114 -0
- data/lib/quarry/grammar/legacy/assert.rb +280 -0
- data/lib/quarry/grammar/should.rb +50 -0
- data/lib/quarry/grammar.rb +4 -0
- data/lib/quarry/{spec → markup}/step.rb +4 -3
- data/lib/quarry/markup.rb +70 -0
- data/lib/quarry/{stub/mock.rb → mock.rb} +1 -1
- data/lib/quarry/{loadmonitor.rb → monitor.rb} +0 -0
- data/lib/quarry/{stub/probe.rb → probe.rb} +8 -35
- data/lib/quarry/reporter/dotprogress.rb +62 -0
- data/lib/quarry/reporter/summary.rb +70 -0
- data/lib/quarry/reporter/verbatim.rb +82 -0
- data/lib/quarry/reporter.rb +70 -0
- data/lib/quarry/{spec → runner}/context.rb +7 -2
- data/lib/quarry/runner.rb +123 -0
- data/lib/quarry/{stub/stub.rb → stub.rb} +1 -1
- data/lib/quarry.rb +10 -0
- data/spec/basic.rd +0 -2
- data/spec/complex.rd +0 -2
- data/spec/mock.rd +20 -26
- data/spec/stub.rd +8 -12
- metadata +48 -361
- data/bin/ruby-break +0 -10
- data/doc/assets/images/clipboard.jpg +0 -0
- data/doc/assets/images/clipboard2.png +0 -0
- data/doc/assets/images/darksilver.png +0 -0
- data/doc/assets/images/icon/book.jpg +0 -0
- data/doc/assets/images/icon/download.gif +0 -0
- data/doc/assets/images/icon/letter_r.png +0 -0
- data/doc/assets/images/icon/license.png +0 -0
- data/doc/assets/images/icon/software.png +0 -0
- data/doc/assets/images/icon/source.png +0 -0
- data/doc/assets/images/miner.jpg +0 -0
- data/doc/assets/images/rbrylmtrx.png +0 -0
- data/doc/assets/images/ruby.gif +0 -0
- data/doc/assets/images/runneth.png +0 -0
- data/doc/assets/images/silver.gif +0 -0
- data/doc/assets/images/test.jpg +0 -0
- data/doc/assets/jquery/jquery.js +0 -1
- data/doc/assets/jquery/jquery.tabs.js +0 -1
- data/doc/assets/rdoc_ad.html +0 -12
- data/doc/assets/styles/index.css +0 -138
- data/doc/guide/stubs.md +0 -125
- data/doc/index.html +0 -285
- data/doc/log/bstats/stats.html +0 -39
- data/doc/log/notes.xml +0 -32
- data/doc/log/stats.html +0 -25
- data/doc/log/stats.log +0 -14
- data/doc/log/syntax.log +0 -0
- data/doc/rdoc/classes/Assertion/False.html +0 -177
- data/doc/rdoc/classes/Assertion/True.html +0 -152
- data/doc/rdoc/classes/Assertion.html +0 -171
- data/doc/rdoc/classes/Kernel.html +0 -105
- data/doc/rdoc/classes/Method.html +0 -168
- data/doc/rdoc/classes/Object.html +0 -507
- data/doc/rdoc/classes/Quarry/Break.html +0 -231
- data/doc/rdoc/classes/Quarry/Command.html +0 -443
- data/doc/rdoc/classes/Quarry/Extract.html +0 -215
- data/doc/rdoc/classes/Quarry/MethodProbe.html +0 -325
- data/doc/rdoc/classes/Quarry/Mock/Delegator.html +0 -179
- data/doc/rdoc/classes/Quarry/Mock/Setter.html +0 -175
- data/doc/rdoc/classes/Quarry/Mock.html +0 -233
- data/doc/rdoc/classes/Quarry/Spec/Comment.html +0 -237
- data/doc/rdoc/classes/Quarry/Spec/Config.html +0 -257
- data/doc/rdoc/classes/Quarry/Spec/Context.html +0 -154
- data/doc/rdoc/classes/Quarry/Spec/Document.html +0 -382
- data/doc/rdoc/classes/Quarry/Spec/Header.html +0 -195
- data/doc/rdoc/classes/Quarry/Spec/Macro.html +0 -166
- data/doc/rdoc/classes/Quarry/Spec/Markup.html +0 -279
- data/doc/rdoc/classes/Quarry/Spec/Reporter/DotProgress.html +0 -234
- data/doc/rdoc/classes/Quarry/Spec/Reporter/Summary.html +0 -294
- data/doc/rdoc/classes/Quarry/Spec/Reporter/Verbatim.html +0 -311
- data/doc/rdoc/classes/Quarry/Spec/Runner.html +0 -352
- data/doc/rdoc/classes/Quarry/Spec/Step.html +0 -190
- data/doc/rdoc/classes/Quarry/Spec/Template.html +0 -205
- data/doc/rdoc/classes/Quarry/Stub/Delegator.html +0 -179
- data/doc/rdoc/classes/Quarry/Stub/Setter.html +0 -175
- data/doc/rdoc/classes/Quarry/Stub.html +0 -224
- data/doc/rdoc/classes/Quarry.html +0 -176
- data/doc/rdoc/created.rid +0 -1
- data/doc/rdoc/files/CHANGES.html +0 -150
- data/doc/rdoc/files/COPYING.html +0 -468
- data/doc/rdoc/files/README.html +0 -195
- data/doc/rdoc/files/RELEASE.html +0 -122
- data/doc/rdoc/files/VERSION.html +0 -107
- data/doc/rdoc/files/bin/quarry-doc.html +0 -109
- data/doc/rdoc/files/bin/quarry.html +0 -109
- data/doc/rdoc/files/bin/ruby-break.html +0 -108
- data/doc/rdoc/files/bin/ruby-xacto.html +0 -101
- data/doc/rdoc/files/lib/quarry/assert_rb.html +0 -155
- data/doc/rdoc/files/lib/quarry/break_rb.html +0 -101
- data/doc/rdoc/files/lib/quarry/extract_rb.html +0 -108
- data/doc/rdoc/files/lib/quarry/loadmonitor_rb.html +0 -101
- data/doc/rdoc/files/lib/quarry/spec/config_rb.html +0 -101
- data/doc/rdoc/files/lib/quarry/spec/context_rb.html +0 -101
- data/doc/rdoc/files/lib/quarry/spec/document_rb.html +0 -111
- data/doc/rdoc/files/lib/quarry/spec/markup_rb.html +0 -108
- data/doc/rdoc/files/lib/quarry/spec/reporter/dotprogress_rb.html +0 -108
- data/doc/rdoc/files/lib/quarry/spec/reporter/summary_rb.html +0 -108
- data/doc/rdoc/files/lib/quarry/spec/reporter/verbatim_rb.html +0 -108
- data/doc/rdoc/files/lib/quarry/spec/reporter_rb.html +0 -109
- data/doc/rdoc/files/lib/quarry/spec/runner_rb.html +0 -109
- data/doc/rdoc/files/lib/quarry/spec/step_rb.html +0 -101
- data/doc/rdoc/files/lib/quarry/spec/template_rhtml.html +0 -228
- data/doc/rdoc/files/lib/quarry/spec_rb.html +0 -113
- data/doc/rdoc/files/lib/quarry/stub/mock_rb.html +0 -101
- data/doc/rdoc/files/lib/quarry/stub/probe_rb.html +0 -122
- data/doc/rdoc/files/lib/quarry/stub/spec_txt.html +0 -118
- data/doc/rdoc/files/lib/quarry/stub/stub_rb.html +0 -101
- data/doc/rdoc/fr_class_index.html +0 -56
- data/doc/rdoc/fr_file_index.html +0 -55
- data/doc/rdoc/fr_method_index.html +0 -117
- data/doc/rdoc/index.html +0 -24
- data/doc/rdoc/rdoc-style.css +0 -208
- data/doc/ri/Assertion/False/assert-i.yaml +0 -10
- data/doc/ri/Assertion/False/cdesc-False.yaml +0 -21
- data/doc/ri/Assertion/False/message-i.yaml +0 -10
- data/doc/ri/Assertion/True/assert-i.yaml +0 -11
- data/doc/ri/Assertion/True/cdesc-True.yaml +0 -26
- data/doc/ri/Assertion/True/message-c.yaml +0 -11
- data/doc/ri/Assertion/True/message-i.yaml +0 -11
- data/doc/ri/Assertion/True/method_missing-i.yaml +0 -12
- data/doc/ri/Assertion/True/new-c.yaml +0 -11
- data/doc/ri/Assertion/cdesc-Assertion.yaml +0 -40
- data/doc/ri/Kernel/cdesc-Kernel.yaml +0 -15
- data/doc/ri/Method/cdesc-Method.yaml +0 -18
- data/doc/ri/Method/migration-i.yaml +0 -12
- data/doc/ri/Method/signature-i.yaml +0 -12
- data/doc/ri/Object/assert%21-i.yaml +0 -17
- data/doc/ri/Object/assert-i.yaml +0 -15
- data/doc/ri/Object/assert_raises%21-i.yaml +0 -12
- data/doc/ri/Object/assert_raises-i.yaml +0 -15
- data/doc/ri/Object/cdesc-Object.yaml +0 -42
- data/doc/ri/Object/mock-i.yaml +0 -12
- data/doc/ri/Object/refute-i.yaml +0 -13
- data/doc/ri/Object/refute_raises-i.yaml +0 -17
- data/doc/ri/Object/remove-i.yaml +0 -12
- data/doc/ri/Object/should-i.yaml +0 -12
- data/doc/ri/Object/should_not-i.yaml +0 -12
- data/doc/ri/Object/should_not_raise-i.yaml +0 -12
- data/doc/ri/Object/should_raise-i.yaml +0 -12
- data/doc/ri/Object/stub-i.yaml +0 -12
- data/doc/ri/Quarry/Break/cdesc-Break.yaml +0 -23
- data/doc/ri/Quarry/Break/edit-i.yaml +0 -11
- data/doc/ri/Quarry/Break/new-c.yaml +0 -11
- data/doc/ri/Quarry/Extract/cdesc-Extract.yaml +0 -26
- data/doc/ri/Quarry/Extract/create_test-i.yaml +0 -12
- data/doc/ri/Quarry/Extract/extract_test_from_file-i.yaml +0 -12
- data/doc/ri/Quarry/Extract/test_extract-i.yaml +0 -18
- data/doc/ri/Quarry/MethodProbe/cdesc-MethodProbe.yaml +0 -46
- data/doc/ri/Quarry/MethodProbe/duckcall-c.yaml +0 -10
- data/doc/ri/Quarry/MethodProbe/initialize_copy-i.yaml +0 -10
- data/doc/ri/Quarry/MethodProbe/method_missing-i.yaml +0 -10
- data/doc/ri/Quarry/MethodProbe/new-c.yaml +0 -10
- data/doc/ri/Quarry/Mock/Delegator/cdesc-Delegator.yaml +0 -20
- data/doc/ri/Quarry/Mock/Delegator/method_missing-i.yaml +0 -10
- data/doc/ri/Quarry/Mock/Delegator/new-c.yaml +0 -10
- data/doc/ri/Quarry/Mock/Setter/%3d%3d-i.yaml +0 -10
- data/doc/ri/Quarry/Mock/Setter/cdesc-Setter.yaml +0 -18
- data/doc/ri/Quarry/Mock/Setter/new-c.yaml +0 -10
- data/doc/ri/Quarry/Mock/__table__-i.yaml +0 -11
- data/doc/ri/Quarry/Mock/cdesc-Mock.yaml +0 -25
- data/doc/ri/Quarry/Mock/method_missing-i.yaml +0 -12
- data/doc/ri/Quarry/Mock/new-c.yaml +0 -10
- data/doc/ri/Quarry/Spec/Comment/cdesc-Comment.yaml +0 -33
- data/doc/ri/Quarry/Spec/Comment/macro%3f-i.yaml +0 -12
- data/doc/ri/Quarry/Spec/Comment/new-c.yaml +0 -10
- data/doc/ri/Quarry/Spec/Comment/type-i.yaml +0 -12
- data/doc/ri/Quarry/Spec/Config/after-i.yaml +0 -12
- data/doc/ri/Quarry/Spec/Config/after_spec-i.yaml +0 -12
- data/doc/ri/Quarry/Spec/Config/before-i.yaml +0 -12
- data/doc/ri/Quarry/Spec/Config/before_spec-i.yaml +0 -12
- data/doc/ri/Quarry/Spec/Config/cdesc-Config.yaml +0 -26
- data/doc/ri/Quarry/Spec/Config/new-c.yaml +0 -10
- data/doc/ri/Quarry/Spec/Context/cdesc-Context.yaml +0 -21
- data/doc/ri/Quarry/Spec/Context/new-c.yaml +0 -10
- data/doc/ri/Quarry/Spec/Document/cdesc-Document.yaml +0 -76
- data/doc/ri/Quarry/Spec/Document/generate-i.yaml +0 -12
- data/doc/ri/Quarry/Spec/Document/new-c.yaml +0 -12
- data/doc/ri/Quarry/Spec/Document/quiet%3f-i.yaml +0 -12
- data/doc/ri/Quarry/Spec/Document/require_rdoc-i.yaml +0 -11
- data/doc/ri/Quarry/Spec/Document/save-i.yaml +0 -12
- data/doc/ri/Quarry/Spec/Document/template-i.yaml +0 -12
- data/doc/ri/Quarry/Spec/Header/cdesc-Header.yaml +0 -30
- data/doc/ri/Quarry/Spec/Header/new-c.yaml +0 -10
- data/doc/ri/Quarry/Spec/Macro/cdesc-Macro.yaml +0 -22
- data/doc/ri/Quarry/Spec/Macro/new-c.yaml +0 -10
- data/doc/ri/Quarry/Spec/Markup/cdesc-Markup.yaml +0 -31
- data/doc/ri/Quarry/Spec/Markup/description-i.yaml +0 -11
- data/doc/ri/Quarry/Spec/Markup/new-c.yaml +0 -11
- data/doc/ri/Quarry/Spec/Markup/parse-i.yaml +0 -11
- data/doc/ri/Quarry/Spec/Markup/parse_section-i.yaml +0 -11
- data/doc/ri/Quarry/Spec/Reporter/DotProgress/cdesc-DotProgress.yaml +0 -21
- data/doc/ri/Quarry/Spec/Reporter/DotProgress/report_intro-i.yaml +0 -10
- data/doc/ri/Quarry/Spec/Reporter/DotProgress/report_step-i.yaml +0 -10
- data/doc/ri/Quarry/Spec/Reporter/DotProgress/report_summary-i.yaml +0 -16
- data/doc/ri/Quarry/Spec/Reporter/Summary/cdesc-Summary.yaml +0 -31
- data/doc/ri/Quarry/Spec/Reporter/Summary/report_comment-i.yaml +0 -10
- data/doc/ri/Quarry/Spec/Reporter/Summary/report_error-i.yaml +0 -10
- data/doc/ri/Quarry/Spec/Reporter/Summary/report_fail-i.yaml +0 -10
- data/doc/ri/Quarry/Spec/Reporter/Summary/report_header-i.yaml +0 -10
- data/doc/ri/Quarry/Spec/Reporter/Summary/report_macro-i.yaml +0 -10
- data/doc/ri/Quarry/Spec/Reporter/Summary/report_pass-i.yaml +0 -10
- data/doc/ri/Quarry/Spec/Reporter/Verbatim/cdesc-Verbatim.yaml +0 -29
- data/doc/ri/Quarry/Spec/Reporter/Verbatim/report_comment-i.yaml +0 -10
- data/doc/ri/Quarry/Spec/Reporter/Verbatim/report_error-i.yaml +0 -10
- data/doc/ri/Quarry/Spec/Reporter/Verbatim/report_fail-i.yaml +0 -10
- data/doc/ri/Quarry/Spec/Reporter/Verbatim/report_header-i.yaml +0 -16
- data/doc/ri/Quarry/Spec/Reporter/Verbatim/report_macro-i.yaml +0 -10
- data/doc/ri/Quarry/Spec/Reporter/Verbatim/report_pass-i.yaml +0 -10
- data/doc/ri/Quarry/Spec/Reporter/cdesc-Reporter.yaml +0 -20
- data/doc/ri/Quarry/Spec/Runner/cdesc-Runner.yaml +0 -47
- data/doc/ri/Quarry/Spec/Runner/check-i.yaml +0 -12
- data/doc/ri/Quarry/Spec/Runner/check_spec-i.yaml +0 -12
- data/doc/ri/Quarry/Spec/Runner/new-c.yaml +0 -12
- data/doc/ri/Quarry/Spec/Runner/run_step-i.yaml +0 -12
- data/doc/ri/Quarry/Spec/Step/cdesc-Step.yaml +0 -30
- data/doc/ri/Quarry/Spec/Step/new-c.yaml +0 -10
- data/doc/ri/Quarry/Spec/Template/cdesc-Template.yaml +0 -31
- data/doc/ri/Quarry/Spec/Template/new-c.yaml +0 -11
- data/doc/ri/Quarry/Spec/Template/parse_template-i.yaml +0 -10
- data/doc/ri/Quarry/Spec/cdesc-Spec.yaml +0 -15
- data/doc/ri/Quarry/Stub/Delegator/cdesc-Delegator.yaml +0 -20
- data/doc/ri/Quarry/Stub/Delegator/method_missing-i.yaml +0 -10
- data/doc/ri/Quarry/Stub/Delegator/new-c.yaml +0 -10
- data/doc/ri/Quarry/Stub/Setter/%3d%3d-i.yaml +0 -10
- data/doc/ri/Quarry/Stub/Setter/cdesc-Setter.yaml +0 -18
- data/doc/ri/Quarry/Stub/Setter/new-c.yaml +0 -10
- data/doc/ri/Quarry/Stub/__table__-i.yaml +0 -11
- data/doc/ri/Quarry/Stub/cdesc-Stub.yaml +0 -23
- data/doc/ri/Quarry/Stub/method_missing-i.yaml +0 -11
- data/doc/ri/Quarry/Stub/new-c.yaml +0 -10
- data/doc/ri/Quarry/cdesc-Quarry.yaml +0 -16
- data/doc/ri/created.rid +0 -1
- data/doc/spec/stub.html +0 -394
- data/lib/quarry/assert.rb +0 -198
- data/lib/quarry/break.rb +0 -51
- data/lib/quarry/spec/document.rb +0 -130
- data/lib/quarry/spec/markup.rb +0 -85
- data/lib/quarry/spec/reporter/dotprogress.rb +0 -66
- data/lib/quarry/spec/reporter/summary.rb +0 -74
- data/lib/quarry/spec/reporter/verbatim.rb +0 -87
- data/lib/quarry/spec/reporter.rb +0 -74
- data/lib/quarry/spec/runner.rb +0 -127
- data/lib/quarry/spec/template.rhtml +0 -116
- data/lib/quarry/spec.rb +0 -7
- data/lib/quarry/stub/spec.txt +0 -113
- data/work/consider/document.rb +0 -35
- data/work/consider/fixture.rb +0 -153
- data/work/deprecated/assert/must.rb +0 -9
- data/work/deprecated/assert/should.rb +0 -9
- data/work/deprecated/build.rb +0 -82
- data/work/deprecated/mock/file.rb +0 -11
- data/work/deprecated/mock/mock.0.rb +0 -77
- data/work/deprecated/overlay.rb +0 -64
- data/work/deprecated/spec.rb +0 -195
- data/work/deprecated/stub/stub.0.rb +0 -180
- data/work/deprecated/stub/stub.1.rb +0 -114
- data/work/deprecated/stub/test_stub.rb +0 -66
- data/work/deprecated/test/case.rb +0 -141
- data/work/sandbox/assert.rb +0 -100
- data/work/sandbox/bug.rb +0 -49
- data/work/sandbox/build/announce.rb +0 -213
- data/work/sandbox/build/check.rb +0 -109
- data/work/sandbox/build/gem.rb +0 -235
- data/work/sandbox/build/make.rb +0 -118
- data/work/sandbox/build/manpage.rb +0 -201
- data/work/sandbox/build/notes.rb +0 -214
- data/work/sandbox/build/pack.rb +0 -228
- data/work/sandbox/build/rdoc.rb +0 -289
- data/work/sandbox/build/rubyforge.rb +0 -91
- data/work/sandbox/build/sign.rb +0 -241
- data/work/sandbox/build/stamp.rb +0 -37
- data/work/sandbox/build/stats.rb +0 -154
- data/work/sandbox/build/svn.rb +0 -193
- data/work/sandbox/build/test.rb +0 -521
- data/work/sandbox/design.rb +0 -200
- data/work/sandbox/iface_scanner.rb +0 -102
- data/work/sandbox/testunit/assertions/assert_has_keys.rb +0 -38
- data/work/sandbox/testunit/assertions/assert_has_only_keys.rb +0 -38
- data/work/sandbox/testunit/unit.rb +0 -104
- data/work/sandbox/unitspec.rb +0 -54
- data/work/sandbox/x_isotest.rb +0 -532
@@ -0,0 +1,280 @@
|
|
1
|
+
module Quarry
|
2
|
+
|
3
|
+
module Grammar #:nodoc:
|
4
|
+
|
5
|
+
module Legacy #:nodoc:
|
6
|
+
|
7
|
+
# = Test::Unit Legacy Assertions
|
8
|
+
#
|
9
|
+
# This module provides a compatibility layer for Test::Unit.
|
10
|
+
# This is an optional module and is intended for providing
|
11
|
+
# an easier transition from Test::Unit::TestCase to Quarry
|
12
|
+
# Specifications.
|
13
|
+
#
|
14
|
+
# Note that two methods are not provided, +#assert_nothing_raised+,
|
15
|
+
# and +#assert_nothing_thrown+.
|
16
|
+
#
|
17
|
+
module Assertions
|
18
|
+
|
19
|
+
# The assertion upon which all other assertions are based.
|
20
|
+
#
|
21
|
+
# assert [1, 2].include?(5)
|
22
|
+
#
|
23
|
+
def assert(test=nil, msg=nil)
|
24
|
+
if test
|
25
|
+
msg = "failed assertion (no message given)") unless msg
|
26
|
+
raise Excpectation.new(:message=>msg) unless test
|
27
|
+
else
|
28
|
+
Expectation.new(:delegate=>self)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Passes if the block yields true.
|
33
|
+
#
|
34
|
+
# assert_block "Couldn't do the thing" do
|
35
|
+
# do_the_thing
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
def assert_block(msg=nil) # :yields:
|
39
|
+
test = ! yield
|
40
|
+
msg = "assertion failed" unless msg
|
41
|
+
assert(test, msg)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Passes if expected == +actual.
|
45
|
+
#
|
46
|
+
# Note that the ordering of arguments is important,
|
47
|
+
# since a helpful error message is generated when this
|
48
|
+
# one fails that tells you the values of expected and actual.
|
49
|
+
#
|
50
|
+
# assert_equal 'MY STRING', 'my string'.upcase
|
51
|
+
#
|
52
|
+
def assert_equal(exp, act, msg=nil)
|
53
|
+
test = (exp == act)
|
54
|
+
msg = "Expected #{act.inspect} to be equal to #{exp.inspect}" unless msg
|
55
|
+
assert(test, msg)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Passes if expected_float and actual_float are equal within delta tolerance.
|
59
|
+
#
|
60
|
+
# assert_in_delta 0.05, (50000.0 / 10**6), 0.00001
|
61
|
+
#
|
62
|
+
def assert_in_delta(exp, act, delta, msg=nil)
|
63
|
+
test = (exp.to_f - act.to_f).abs <= delta.to_f
|
64
|
+
msg = "Expected #{exp} to be within #{delta} of #{act}" unless msg
|
65
|
+
assert(test, msg)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Passes if object .instance_of? klass
|
69
|
+
#
|
70
|
+
# assert_instance_of String, 'foo'
|
71
|
+
#
|
72
|
+
def assert_instance_of(cls, obj, msg=nil)
|
73
|
+
test = (cls === obj)
|
74
|
+
msg = "Expected #{obj} to be a #{cls}" unless msg
|
75
|
+
assert(test, msg)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Passes if object .kind_of? klass
|
79
|
+
#
|
80
|
+
# assert_kind_of Object, 'foo'
|
81
|
+
#
|
82
|
+
def assert_kind_of(cls, obj, msg=nil)
|
83
|
+
test = obj.kind_of?(cls)
|
84
|
+
msg = "Expected #{obj.inspect} to be a kind of #{cls}" unless msg
|
85
|
+
assert(test, msg)
|
86
|
+
end
|
87
|
+
|
88
|
+
# Passes if string =~ pattern.
|
89
|
+
#
|
90
|
+
# assert_match(/\d+/, 'five, 6, seven')
|
91
|
+
#
|
92
|
+
def assert_match(exp, act, msg=nil)
|
93
|
+
test = (act =~ exp)
|
94
|
+
msg = "Expected #{act.inspect} to match #{exp.inspect}" unless msg
|
95
|
+
assert(test, msg)
|
96
|
+
end
|
97
|
+
|
98
|
+
# Passes if object is nil.
|
99
|
+
#
|
100
|
+
# assert_nil [1, 2].uniq!
|
101
|
+
#
|
102
|
+
def assert_nil(obj, msg=nil)
|
103
|
+
test = obj.nil?
|
104
|
+
msg = "Expected #{obj.inspect} to be nil" unless msg
|
105
|
+
assert(test, msg)
|
106
|
+
end
|
107
|
+
|
108
|
+
# Passes if regexp !~ string
|
109
|
+
#
|
110
|
+
# assert_no_match(/two/, 'one 2 three')
|
111
|
+
#
|
112
|
+
def assert_no_match(exp, act, msg=nil)
|
113
|
+
test = (act !~ exp)
|
114
|
+
msg = "Expected #{act.inspect} to match #{exp.inspect}" unless msg
|
115
|
+
assert(test, msg)
|
116
|
+
end
|
117
|
+
|
118
|
+
# Passes if expected != actual
|
119
|
+
#
|
120
|
+
# assert_not_equal 'some string', 5
|
121
|
+
#
|
122
|
+
def assert_not_equal(exp, act, msg=nil)
|
123
|
+
test = (exp != act)
|
124
|
+
msg = "Expected #{act.inspect} to not be equal to #{exp.inspect}" unless msg
|
125
|
+
assert(test, msg)
|
126
|
+
end
|
127
|
+
|
128
|
+
# Passes if ! object .nil?
|
129
|
+
#
|
130
|
+
# assert_not_nil '1 two 3'.sub!(/two/, '2')
|
131
|
+
#
|
132
|
+
def assert_not_nil(obj, msg=nil)
|
133
|
+
test = ! obj.nil?
|
134
|
+
msg = "Expected #{obj.inspect} to not be nil" unless msg
|
135
|
+
assert(test, msg)
|
136
|
+
end
|
137
|
+
|
138
|
+
# Passes if ! actual .equal? expected
|
139
|
+
#
|
140
|
+
# assert_not_same Object.new, Object.new
|
141
|
+
#
|
142
|
+
def assert_not_same(exp, act, msg=nil)
|
143
|
+
test = ! exp.equal?(act)
|
144
|
+
msg = "Expected #{act.inspect} to not be the same as #{exp.inspect}" unless msg
|
145
|
+
assert(test, msg)
|
146
|
+
end
|
147
|
+
|
148
|
+
# Compares the +object1+ with +object2+ using operator.
|
149
|
+
#
|
150
|
+
# Passes if object1.send(operator, object2) is true.
|
151
|
+
#
|
152
|
+
# assert_operator 5, :>=, 4
|
153
|
+
#
|
154
|
+
def assert_operator(o1, op, o2, msg="")
|
155
|
+
test = o1.__send__(op, o2)
|
156
|
+
msg = "Expected #{o1}.#{op}(#{o2}) to be true" unless msg
|
157
|
+
assert(test, msg)
|
158
|
+
end
|
159
|
+
|
160
|
+
# Passes if the block raises one of the given exceptions.
|
161
|
+
#
|
162
|
+
# assert_raise RuntimeError, LoadError do
|
163
|
+
# raise 'Boom!!!'
|
164
|
+
# end
|
165
|
+
#
|
166
|
+
def assert_raises(*args)
|
167
|
+
if msg = (Module === args.last ? nil : args.pop)
|
168
|
+
begin
|
169
|
+
yield
|
170
|
+
msg = "Expected #{exp} to be raised" unless msg
|
171
|
+
assert false, msg
|
172
|
+
rescue Exception => e
|
173
|
+
test = (exp === e)
|
174
|
+
msg = "Expected #{exp} to be raised, but got #{e.class}" unless msg
|
175
|
+
assert test, msg
|
176
|
+
return e
|
177
|
+
end
|
178
|
+
end
|
179
|
+
alias_method :assert_raise, :assert_raises
|
180
|
+
|
181
|
+
# Provides a way to assert that a procedure
|
182
|
+
# <i>does not</i> raise an exception.
|
183
|
+
#
|
184
|
+
# refute_raises(StandardError){ raise }
|
185
|
+
#
|
186
|
+
#def assert_raises!(exception, &block)
|
187
|
+
# begin
|
188
|
+
# block.call(*a)
|
189
|
+
# rescue exception
|
190
|
+
# raise Assertion
|
191
|
+
# end
|
192
|
+
#end
|
193
|
+
#alias_method :refute_raises, :assert_raises!
|
194
|
+
|
195
|
+
# Passes if +object+ respond_to? +method+.
|
196
|
+
#
|
197
|
+
# assert_respond_to 'bugbear', :slice
|
198
|
+
#
|
199
|
+
def assert_respond_to(obj, meth, msg=nil)
|
200
|
+
msg = "Expected #{obj} (#{obj.class}) to respond to ##{meth}" unless msg
|
201
|
+
#flip = (Symbol === obj) && ! (Symbol === meth) # HACK for specs
|
202
|
+
#obj, meth = meth, obj if flip
|
203
|
+
test = obj.respond_to?(meth)
|
204
|
+
assert(test, msg)
|
205
|
+
end
|
206
|
+
|
207
|
+
# Passes if +actual+ .equal? +expected+ (i.e. they are the same instance).
|
208
|
+
#
|
209
|
+
# o = Object.new
|
210
|
+
# assert_same(o, o)
|
211
|
+
#
|
212
|
+
def assert_same(exp, act, msg=nil)
|
213
|
+
msg = "Expected #{act.inspect} to be the same as #{exp.inspect}" unless msg
|
214
|
+
test = exp.equal?(act)
|
215
|
+
assert(test, msg)
|
216
|
+
end
|
217
|
+
|
218
|
+
# Passes if the method send returns a true value.
|
219
|
+
# The parameter +send_array+ is composed of:
|
220
|
+
#
|
221
|
+
# * A receiver
|
222
|
+
# * A method
|
223
|
+
# * Arguments to the method
|
224
|
+
#
|
225
|
+
# Example:
|
226
|
+
#
|
227
|
+
# assert_send [[1, 2], :include?, 4]
|
228
|
+
#
|
229
|
+
def assert_send(send_array, msg=nil)
|
230
|
+
r, m, *args = *send_array
|
231
|
+
test = r.__send__(m, *args)
|
232
|
+
msg = "Expected #{r}.#{m}(*#{args.inspect}) to return true" unless msg
|
233
|
+
assert(test, msg)
|
234
|
+
end
|
235
|
+
|
236
|
+
# Passes if the block throws expected_symbol
|
237
|
+
#
|
238
|
+
# assert_throws :done do
|
239
|
+
# throw :done
|
240
|
+
# end
|
241
|
+
#
|
242
|
+
def assert_throws(sym, msg=nil)
|
243
|
+
msg = "Expected #{sym} to have been thrown" unless msg
|
244
|
+
test = true
|
245
|
+
catch(sym) do
|
246
|
+
begin
|
247
|
+
yield
|
248
|
+
rescue ArgumentError => e # 1.9 exception
|
249
|
+
default += ", not #{e.message.split(/ /).last}"
|
250
|
+
rescue NameError => e # 1.8 exception
|
251
|
+
default += ", not #{e.name.inspect}"
|
252
|
+
end
|
253
|
+
test = false
|
254
|
+
end
|
255
|
+
assert(test, msg)
|
256
|
+
end
|
257
|
+
|
258
|
+
# Flunk always fails.
|
259
|
+
#
|
260
|
+
# flunk 'Not done testing yet.'
|
261
|
+
#
|
262
|
+
def flunk(msg=nil)
|
263
|
+
assert(false, msg)
|
264
|
+
end
|
265
|
+
|
266
|
+
end #module Assertions
|
267
|
+
|
268
|
+
end #module Legacy
|
269
|
+
|
270
|
+
end #module Grammar
|
271
|
+
|
272
|
+
# This could be in Object, but since they will only be needed in
|
273
|
+
# the context of a, well, Context...
|
274
|
+
#
|
275
|
+
class Context #:nodoc:
|
276
|
+
include Grammar::Legacy::Assertions
|
277
|
+
end
|
278
|
+
|
279
|
+
end #module Quarry
|
280
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Quarry
|
2
|
+
|
3
|
+
module Grammar
|
4
|
+
|
5
|
+
# = Should Nomenclature
|
6
|
+
#
|
7
|
+
# The term *should* has become the defacto standard for
|
8
|
+
# BDD assertions, so Quarry supports this nomenclature.
|
9
|
+
#
|
10
|
+
module Should
|
11
|
+
|
12
|
+
# Same as #expect but only as a functor.
|
13
|
+
#
|
14
|
+
# 4.should == 3 #=> Expectation Error
|
15
|
+
#
|
16
|
+
def should
|
17
|
+
return Expectation.new(:delegate=>self, :backtrace=>caller)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Designate a negated expectation via a *functor*.
|
21
|
+
# Read this as "should not".
|
22
|
+
#
|
23
|
+
# 4.should! == 4 #=> Expectation Error
|
24
|
+
#
|
25
|
+
# See also #expect!
|
26
|
+
#
|
27
|
+
def should!
|
28
|
+
return Expectation.new(:delagte=>self, :negate=>true, :backtrace=>caller)
|
29
|
+
end
|
30
|
+
|
31
|
+
# See #should! method.
|
32
|
+
#
|
33
|
+
alias_method :should_not, :should!
|
34
|
+
|
35
|
+
#
|
36
|
+
#alias_method :should_raise, :assert_raises
|
37
|
+
|
38
|
+
#
|
39
|
+
#alias_method :should_not_raise, :assert_raises!
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
class ::Object #:nodoc:
|
46
|
+
include Grammar::Should
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'quarry/markup/step'
|
2
|
+
|
3
|
+
module Quarry
|
4
|
+
|
5
|
+
# = Specification Markup
|
6
|
+
#
|
7
|
+
class Markup
|
8
|
+
|
9
|
+
attr :file
|
10
|
+
attr :steps
|
11
|
+
|
12
|
+
#
|
13
|
+
def initialize(file)
|
14
|
+
@file = file
|
15
|
+
@steps = []
|
16
|
+
parse
|
17
|
+
end
|
18
|
+
|
19
|
+
#
|
20
|
+
def parse
|
21
|
+
lineno = 0
|
22
|
+
text = ''
|
23
|
+
File.open(file, 'r') do |f|
|
24
|
+
f.readlines.each_with_index do |line, lineno|
|
25
|
+
case line
|
26
|
+
when /^\s*$/
|
27
|
+
parse_section(text, lineno)
|
28
|
+
text = ''
|
29
|
+
else
|
30
|
+
text << line
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
#
|
37
|
+
def parse_section(text, lineno)
|
38
|
+
return if text.strip == ''
|
39
|
+
case text
|
40
|
+
when /\A[-=].*?$/, /[-=]\s*\Z/
|
41
|
+
#text << line
|
42
|
+
steps << Header.new(self, text, lineno)
|
43
|
+
when /^\s+/
|
44
|
+
last = steps.last
|
45
|
+
case last
|
46
|
+
when Step, Macro
|
47
|
+
last.code << "\n\n#{text.rstrip}"
|
48
|
+
when Comment
|
49
|
+
if last.macro?
|
50
|
+
steps << Macro.new(self, text, lineno, last.type)
|
51
|
+
else
|
52
|
+
steps << Step.new(self, text, lineno)
|
53
|
+
end
|
54
|
+
else
|
55
|
+
steps << Step.new(self, text, lineno)
|
56
|
+
end
|
57
|
+
else
|
58
|
+
steps << Comment.new(self, text, lineno)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
#
|
63
|
+
def description
|
64
|
+
File.basename(file)
|
65
|
+
end
|
66
|
+
|
67
|
+
end #class Markup
|
68
|
+
|
69
|
+
end#module Quarry
|
70
|
+
|
File without changes
|
@@ -1,26 +1,3 @@
|
|
1
|
-
# = methodprobe.rb
|
2
|
-
#
|
3
|
-
# == Copyright (c) 2004 Thomas Sawyer
|
4
|
-
#
|
5
|
-
# Ruby License
|
6
|
-
#
|
7
|
-
# This module is free software. You may use, modify, and/or redistribute this
|
8
|
-
# software under the same terms as Ruby.
|
9
|
-
#
|
10
|
-
# This program is distributed in the hope that it will be useful, but WITHOUT
|
11
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
12
|
-
# FOR A PARTICULAR PURPOSE.
|
13
|
-
#
|
14
|
-
# == Author(s)
|
15
|
-
#
|
16
|
-
# * Thomas Sawyer
|
17
|
-
|
18
|
-
# Author:: Thomas Sawyer
|
19
|
-
# Copyright:: Copyright (c) 2006 Thomas Sawyer
|
20
|
-
# License:: Ruby License
|
21
|
-
|
22
|
-
#
|
23
|
-
|
24
1
|
module Quarry
|
25
2
|
|
26
3
|
# = Method Probe
|
@@ -64,10 +41,9 @@ module Quarry
|
|
64
41
|
# [{"+"=>[["Fixnum"]]}]
|
65
42
|
# [["+( Fixnum )"]]
|
66
43
|
#
|
44
|
+
class Probe
|
67
45
|
|
68
|
-
|
69
|
-
|
70
|
-
def MethodProbe.duckcall
|
46
|
+
def self.duckcall
|
71
47
|
begin
|
72
48
|
yield
|
73
49
|
rescue TypeError => e
|
@@ -125,13 +101,13 @@ module Quarry
|
|
125
101
|
end
|
126
102
|
|
127
103
|
|
128
|
-
class Method
|
104
|
+
class ::Method
|
129
105
|
|
130
106
|
# Outputs migration information.
|
131
107
|
def migration
|
132
108
|
parameters = []; argc = self.arity
|
133
109
|
if argc > 0
|
134
|
-
argc.times { parameters <<
|
110
|
+
argc.times { parameters << Quarry::Probe.new }
|
135
111
|
Probe.duckcall { self.call(*parameters) }
|
136
112
|
elsif argc < 0
|
137
113
|
raise "(NYI) method takes unlimited arguments"
|
@@ -167,14 +143,8 @@ end
|
|
167
143
|
|
168
144
|
|
169
145
|
|
170
|
-
# _____ _
|
171
|
-
# |_ _|__ ___| |_
|
172
|
-
# | |/ _ \/ __| __|
|
173
|
-
# | | __/\__ \ |_
|
174
|
-
# |_|\___||___/\__|
|
175
|
-
#
|
176
146
|
|
177
|
-
=begin
|
147
|
+
=begin test
|
178
148
|
|
179
149
|
require 'test/unit'
|
180
150
|
|
@@ -214,3 +184,6 @@ end
|
|
214
184
|
end
|
215
185
|
|
216
186
|
=end
|
187
|
+
|
188
|
+
# Copyright (c) 2004,2008 Thomas Sawyer
|
189
|
+
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'quarry/reporter'
|
2
|
+
|
3
|
+
module Quarry
|
4
|
+
|
5
|
+
class Reporter #:nodoc:
|
6
|
+
|
7
|
+
#
|
8
|
+
class DotProgress < Reporter
|
9
|
+
|
10
|
+
def report_intro
|
11
|
+
@start_time = Time.now
|
12
|
+
puts "Started"
|
13
|
+
end
|
14
|
+
|
15
|
+
def report_step(step)
|
16
|
+
super
|
17
|
+
if step.code
|
18
|
+
print "."
|
19
|
+
#str = "(%s) %s" % [count.join('.'), str.tab(6).strip]
|
20
|
+
#puts "* #{step.text.tab(2).strip}"
|
21
|
+
#puts "\n#{step.code}\n" if $VERBOSE
|
22
|
+
else
|
23
|
+
#puts "\n#{step.text}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
#def report(str)
|
28
|
+
# count[-1] += 1 unless count.empty?
|
29
|
+
# str = str.chomp('.') + '.'
|
30
|
+
# str = count.join('.') + ' ' + str
|
31
|
+
# puts str.strip
|
32
|
+
#end
|
33
|
+
|
34
|
+
def report_summary
|
35
|
+
puts "\nFinished in #{Time.now - @start_time} seconds.\n\n"
|
36
|
+
|
37
|
+
@error.each do |step, exception|
|
38
|
+
puts ANSICode.red("***** ERROR *****")
|
39
|
+
puts "#{exception}"
|
40
|
+
puts ":#{exception.backtrace[0]}:"
|
41
|
+
#puts ":#{exception.backtrace[1]}:"
|
42
|
+
#puts exception.backtrace[1..-1] if $VERBOSE
|
43
|
+
puts
|
44
|
+
end
|
45
|
+
|
46
|
+
@fail.each do |step, assertion|
|
47
|
+
puts ANSICode.red("***** FAIL *****")
|
48
|
+
puts ANSICode.bold("#{assertion}")
|
49
|
+
puts ":#{assertion.backtrace[2]}:"
|
50
|
+
#puts assertion if $VERBOSE
|
51
|
+
puts
|
52
|
+
end
|
53
|
+
|
54
|
+
puts "%s specs, %s steps, %s failures, %s errors" % [@specs, @steps, @fail.size, @error.size] #, @pass.size ]
|
55
|
+
end
|
56
|
+
|
57
|
+
end#class DotProgress
|
58
|
+
|
59
|
+
end#class Reporter
|
60
|
+
|
61
|
+
end#module Quarry
|
62
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'quarry/reporter'
|
2
|
+
|
3
|
+
module Quarry
|
4
|
+
|
5
|
+
class Reporter #:nodoc:
|
6
|
+
|
7
|
+
# = Summary Reporter
|
8
|
+
#
|
9
|
+
# Similar to the Verbatim reporter, but does
|
10
|
+
# not display test code for passing tests.
|
11
|
+
|
12
|
+
class Summary < Reporter
|
13
|
+
|
14
|
+
def report_header(step)
|
15
|
+
puts ANSICode.bold(step.text)
|
16
|
+
end
|
17
|
+
|
18
|
+
def report_comment(step)
|
19
|
+
txt = step.text.tabto(2)
|
20
|
+
txt[0,1] = "*"
|
21
|
+
puts txt
|
22
|
+
end
|
23
|
+
|
24
|
+
def report_macro(step)
|
25
|
+
txt = step.text.tabto(2)
|
26
|
+
txt[0,1] = "*"
|
27
|
+
puts txt
|
28
|
+
#puts
|
29
|
+
#puts ANSICode.magenta("#{step.code}")
|
30
|
+
end
|
31
|
+
|
32
|
+
def report_pass(step)
|
33
|
+
#puts ANSICode.green("#{step.code}")
|
34
|
+
end
|
35
|
+
|
36
|
+
def report_fail(step, assertion)
|
37
|
+
msg = ''
|
38
|
+
msg << " ##### FAIL #####\n"
|
39
|
+
msg << " # " + assertion.to_s
|
40
|
+
msg = ANSICode.magenta(msg)
|
41
|
+
puts msg
|
42
|
+
#puts
|
43
|
+
puts ANSICode.red("#{step.code}")
|
44
|
+
end
|
45
|
+
|
46
|
+
def report_error(step, exception)
|
47
|
+
raise exception if $DEBUG
|
48
|
+
msg = ''
|
49
|
+
msg << " ##### ERROR #####\n"
|
50
|
+
msg << " # " + exception.to_s + "\n"
|
51
|
+
msg << " # " + exception.backtrace[0]
|
52
|
+
msg = ANSICode.magenta(msg)
|
53
|
+
puts msg
|
54
|
+
#puts
|
55
|
+
puts ANSICode.red("#{step.code}")
|
56
|
+
end
|
57
|
+
|
58
|
+
#def report(str)
|
59
|
+
# count[-1] += 1 unless count.empty?
|
60
|
+
# str = str.chomp('.') + '.'
|
61
|
+
# str = count.join('.') + ' ' + str
|
62
|
+
# puts str.strip
|
63
|
+
#end
|
64
|
+
|
65
|
+
end #class Summary
|
66
|
+
|
67
|
+
end #class Reporter
|
68
|
+
|
69
|
+
end #module Quarry
|
70
|
+
|