assay 0.4.1 → 0.5.0
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/.yardopts +7 -0
- data/HISTORY.md +128 -0
- data/LICENSE.txt +22 -0
- data/README.md +287 -0
- data/demo/ae/01_overview.md +98 -0
- data/demo/ae/03_assert.md +398 -0
- data/demo/ae/04_subjunctive.md +100 -0
- data/demo/ae/05_expect.md +136 -0
- data/demo/ae/06_counts.md +33 -0
- data/demo/ae/07_matchers.md +34 -0
- data/demo/ae/08_check.md +61 -0
- data/demo/ae/09_assay.md +124 -0
- data/demo/ae/applique/setup.rb +11 -0
- data/{test → demo/applique}/helper.rb +8 -2
- data/demo/applique/setup.rb +1 -0
- data/demo/bang/01_bang.md +220 -0
- data/demo/core/00_introduction.md +2 -0
- data/demo/core/01_assay_classes/00_introduction.md +2 -0
- data/demo/core/01_assay_classes/01_nil_assay.md +35 -0
- data/demo/core/01_assay_classes/02_boolean_assay.md +35 -0
- data/demo/core/01_assay_classes/03_false_assay.md +19 -0
- data/demo/core/01_assay_classes/03_true_assay.md +20 -0
- data/demo/core/01_assay_classes/04_like_assay.md +19 -0
- data/demo/core/01_assay_classes/05_equal_assay.md +19 -0
- data/demo/core/01_assay_classes/06_unequal_assay.md +35 -0
- data/demo/core/01_assay_classes/07_equality_assay.md +19 -0
- data/demo/core/01_assay_classes/08_identity_assay.md +24 -0
- data/demo/core/01_assay_classes/09_case_assay.md +22 -0
- data/demo/core/01_assay_classes/10_match_assay.md +15 -0
- data/demo/core/01_assay_classes/11_nomatch_assay.md +16 -0
- data/demo/core/01_assay_classes/12_compare_assay.md +24 -0
- data/demo/core/01_assay_classes/13_less_assay.md +29 -0
- data/demo/core/01_assay_classes/14_more_assay.md +29 -0
- data/demo/core/01_assay_classes/15_less_equal_assay.md +30 -0
- data/demo/core/01_assay_classes/16_more_equal_assay.md +29 -0
- data/demo/core/01_assay_classes/17_close_assay.md +42 -0
- data/demo/core/01_assay_classes/17_within_assay.md +42 -0
- data/demo/core/01_assay_classes/18_kind_assay.md +17 -0
- data/demo/core/01_assay_classes/19_instance_assay.md +16 -0
- data/demo/core/01_assay_classes/20_include_assay.md +17 -0
- data/demo/core/01_assay_classes/21_empty_assay.md +15 -0
- data/demo/core/01_assay_classes/22_respond_assay.md +15 -0
- data/demo/core/01_assay_classes/23_execution_assay.md +40 -0
- data/demo/core/01_assay_classes/23_return_assay.md +37 -0
- data/demo/core/01_assay_classes/24_rescue_assay.md +40 -0
- data/demo/core/01_assay_classes/25_raise_assay.md +40 -0
- data/demo/core/01_assay_classes/26_throw_assay.md +47 -0
- data/demo/core/01_assay_classes/27_path_assay.md +20 -0
- data/demo/core/01_assay_classes/28_directory_assay.md +21 -0
- data/demo/core/01_assay_classes/29_file_assay.md +20 -0
- data/demo/core/01_assay_classes/30_output_assay.md +39 -0
- data/demo/core/01_assay_classes/31_stdout_assay.md +21 -0
- data/demo/core/01_assay_classes/32_stderr_assay.md +21 -0
- data/demo/core/02_lookup.md +25 -0
- data/demo/core/03_assertor.md +117 -0
- data/demo/core/04_assay.md +40 -0
- data/demo/fluidity/00_intro.md +7 -0
- data/demo/fluidity/01_should.md +52 -0
- data/demo/fluidity/02_must.md +58 -0
- data/demo/fluidity/03_assert.md +71 -0
- data/demo/fluidity/04_other.md +35 -0
- data/demo/fluidity/05_object_methods.md +102 -0
- data/demo/minitest/01_minitest_extensions.rdoc +217 -0
- data/demo/minitest/02_minitest_assertions.rdoc +250 -0
- data/demo/rspec/00_introduction.md +16 -0
- data/demo/rspec/01_should.md +24 -0
- data/demo/rspec/02_matchers.md +176 -0
- data/demo/rspec/03_have.md +51 -0
- data/demo/rspec/04_expect.md +49 -0
- data/demo/rspec/applique/setup.rb +2 -0
- data/demo/testunit/01_testunit_assertions.md +266 -0
- data/lib/assay/adapter/minitest.rb +32 -21
- data/lib/assay/adapter/testunit.rb +31 -38
- data/lib/assay/ae/assert.rb +77 -0
- data/lib/assay/ae/assertor.rb +453 -0
- data/lib/assay/ae/check.rb +154 -0
- data/lib/assay/ae/core_ext.rb +146 -0
- data/lib/assay/ae/expect.rb +72 -0
- data/lib/assay/ae/must.rb +64 -0
- data/lib/assay/ae/should.rb +58 -0
- data/lib/assay/ae/subjunctive.rb +66 -0
- data/lib/assay/ae.rb +29 -0
- data/lib/assay/assertable.rb +21 -5
- data/lib/assay/assertor.rb +4 -4
- data/lib/assay/bang.rb +147 -0
- data/lib/assay/close_assay.rb +2 -2
- data/lib/assay/core_ext/kernel.rb +4 -8
- data/lib/assay/fluidity/assert.rb +27 -0
- data/lib/assay/fluidity/grammar.rb +157 -0
- data/lib/assay/fluidity/is.rb +18 -0
- data/lib/assay/fluidity/must.rb +38 -0
- data/lib/assay/fluidity/should.rb +32 -0
- data/lib/assay/fluidity/will.rb +36 -0
- data/lib/assay/fluidity.rb +6 -0
- data/lib/assay/less_assay.rb +7 -1
- data/lib/assay/less_equal_assay.rb +7 -1
- data/lib/assay/minitest/assertions.rb +495 -0
- data/lib/assay/minitest/extensions.rb +496 -0
- data/lib/assay/minitest.rb +24 -0
- data/lib/assay/more_assay.rb +7 -1
- data/lib/assay/more_equal_assay.rb +7 -1
- data/lib/assay/rspec/expect.rb +151 -0
- data/lib/assay/rspec/have.rb +201 -0
- data/lib/assay/rspec/matchers.rb +272 -0
- data/lib/assay/rspec/operatics.rb +60 -0
- data/lib/assay/rspec/should.rb +49 -0
- data/lib/assay/rspec.rb +13 -0
- data/lib/assay/testunit/assertions.rb +484 -0
- data/lib/assay/testunit.rb +9 -0
- data/lib/assay/version.rb +3 -0
- data/lib/assay.rb +7 -21
- metadata +211 -80
- data/.ruby +0 -51
- data/COPYING.rdoc +0 -38
- data/HISTORY.rdoc +0 -65
- data/QED.rdoc +0 -1143
- data/README.rdoc +0 -173
- data/lib/assay.yml +0 -51
- data/test/case_compare_assay.rb +0 -59
- data/test/case_empty_assay.rb +0 -51
- data/test/case_equal_assay.rb +0 -53
- data/test/case_equality_assay.rb +0 -55
- data/test/case_false_assay.rb +0 -48
- data/test/case_identity_assay.rb +0 -51
- data/test/case_include_assay.rb +0 -51
- data/test/case_instance_assay.rb +0 -51
- data/test/case_kind_assay.rb +0 -51
- data/test/case_less_assay.rb +0 -53
- data/test/case_less_equal_assay.rb +0 -53
- data/test/case_like_assay.rb +0 -57
- data/test/case_match_assay.rb +0 -45
- data/test/case_more_assay.rb +0 -53
- data/test/case_more_equal_assay.rb +0 -53
- data/test/case_nil_assay.rb +0 -48
- data/test/case_nomatch_assay.rb +0 -47
- data/test/case_raise_assay.rb +0 -51
- data/test/case_respond_assay.rb +0 -51
- data/test/case_throw_assay.rb +0 -51
- data/test/case_true_assay.rb +0 -48
- data/test/case_unequal_assay.rb +0 -55
- data/test/case_within_assay.rb +0 -61
|
@@ -10,11 +10,9 @@ module Kernel
|
|
|
10
10
|
object_id == other.object_id
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
# Ascertain likeness, returns true if any of `equal?`, `eql?`,
|
|
14
|
-
# `===`
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
# @todo Should `#=~` be apart of this comparison?
|
|
13
|
+
# Ascertain likeness, returns true if any of `equal?`, `eql?`, `==` or
|
|
14
|
+
# `===` evaluate truthfully, either with `self` as the receiver or
|
|
15
|
+
# `other` as the receiver.
|
|
18
16
|
#
|
|
19
17
|
# @param [Object] other
|
|
20
18
|
# Any object reference.
|
|
@@ -26,12 +24,10 @@ module Kernel
|
|
|
26
24
|
self.eql?(other) ||
|
|
27
25
|
self.==(other) ||
|
|
28
26
|
self.===(other) ||
|
|
29
|
-
self.=~(other) ||
|
|
30
27
|
other.equal?(self) ||
|
|
31
28
|
other.eql?(self) ||
|
|
32
29
|
other.==(self) ||
|
|
33
|
-
other.===(self)
|
|
34
|
-
other.=~(self)
|
|
30
|
+
other.===(self) ? true : false
|
|
35
31
|
end
|
|
36
32
|
|
|
37
33
|
#
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require_relative 'grammar'
|
|
2
|
+
|
|
3
|
+
class Object
|
|
4
|
+
|
|
5
|
+
# Use `assert` nomenclature for assertions.
|
|
6
|
+
#
|
|
7
|
+
# 10.assert.kind_of?(Integer)
|
|
8
|
+
#
|
|
9
|
+
def assert(*args, &blk)
|
|
10
|
+
return ::Assay::Fluidity::Grammar::Assert.new(self) if args.empty?
|
|
11
|
+
|
|
12
|
+
matcher = args.first
|
|
13
|
+
|
|
14
|
+
if ::Assay::Assertor === matcher
|
|
15
|
+
matcher =~ self
|
|
16
|
+
else
|
|
17
|
+
super(*args, &blk)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
module Kernel
|
|
25
|
+
public :assert
|
|
26
|
+
public :refute
|
|
27
|
+
end
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
require_relative '../../assay'
|
|
2
|
+
|
|
3
|
+
module Assay; end
|
|
4
|
+
module Assay::Fluidity
|
|
5
|
+
|
|
6
|
+
module Grammar
|
|
7
|
+
|
|
8
|
+
# The grammar classes are built on BasicObject, so that a method every
|
|
9
|
+
# object has, such as `kind_of?`, `nil?` or `eql?`, makes an assertion
|
|
10
|
+
# about the target rather than being answered by the grammar object.
|
|
11
|
+
class Base < ::BasicObject
|
|
12
|
+
|
|
13
|
+
# BasicObject has a few public methods of its own. Making them private
|
|
14
|
+
# sends them through #method_missing like any other.
|
|
15
|
+
private :!, :equal?, :instance_eval, :instance_exec
|
|
16
|
+
|
|
17
|
+
def initialize(target, negate=false)
|
|
18
|
+
@target = target
|
|
19
|
+
@negate = negate
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Have to override the ususal `#==` method to support this.
|
|
23
|
+
def ==(other)
|
|
24
|
+
if @negate
|
|
25
|
+
::EqualAssay.refute!(@target, other, :backtrace=>::Kernel.caller)
|
|
26
|
+
else
|
|
27
|
+
::EqualAssay.assert!(@target, other, :backtrace=>::Kernel.caller)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Likewise for `#!=`.
|
|
32
|
+
def !=(other)
|
|
33
|
+
if @negate
|
|
34
|
+
::UnequalAssay.refute!(@target, other, :backtrace=>::Kernel.caller)
|
|
35
|
+
else
|
|
36
|
+
::UnequalAssay.assert!(@target, other, :backtrace=>::Kernel.caller)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def method_missing(s, *a, **kw, &b)
|
|
41
|
+
if assay = (::Assertion.by_name(s) || ::Assertion.by_operator(s))
|
|
42
|
+
a << kw unless kw.empty?
|
|
43
|
+
if @negate
|
|
44
|
+
assay.refute!(@target, *a, {:backtrace=>::Kernel.caller}, &b)
|
|
45
|
+
else
|
|
46
|
+
assay.assert!(@target, *a, {:backtrace=>::Kernel.caller}, &b)
|
|
47
|
+
end
|
|
48
|
+
else
|
|
49
|
+
q = (s.to_s.end_with?('?') ? s : (s.to_s+'?'))
|
|
50
|
+
if @target.respond_to?(q)
|
|
51
|
+
truth = @target.__send__(q, *a, **kw, &b)
|
|
52
|
+
args = (a.map{ |x| x.inspect } + kw.map{ |k,v| "#{k}: #{v.inspect}" }).join(', ')
|
|
53
|
+
call = "#{@target.inspect}.#{q}" + (args.empty? ? '' : "(#{args})")
|
|
54
|
+
if @negate
|
|
55
|
+
::Kernel.assert(!truth, ::Assertion, "! #{call}", ::Kernel.caller)
|
|
56
|
+
else
|
|
57
|
+
::Kernel.assert(truth, ::Assertion, call, ::Kernel.caller)
|
|
58
|
+
end
|
|
59
|
+
else
|
|
60
|
+
super
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
#
|
|
68
|
+
class Assert < Base
|
|
69
|
+
|
|
70
|
+
#def method_missing(s, *a, &b)
|
|
71
|
+
# call(s, *a, &b)
|
|
72
|
+
#end
|
|
73
|
+
|
|
74
|
+
def not
|
|
75
|
+
Assert.new(@target, !@negate)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
#
|
|
81
|
+
class Be < Base
|
|
82
|
+
|
|
83
|
+
#def method_missing(s, *a, &b)
|
|
84
|
+
# call(s, *a, &b)
|
|
85
|
+
#end
|
|
86
|
+
|
|
87
|
+
#
|
|
88
|
+
def a
|
|
89
|
+
self
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
#
|
|
93
|
+
def an
|
|
94
|
+
self
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
#
|
|
100
|
+
class Is < Be
|
|
101
|
+
|
|
102
|
+
def not
|
|
103
|
+
Is.new(@target, !@negate)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
#
|
|
109
|
+
class Must < Base
|
|
110
|
+
|
|
111
|
+
#def method_missing(s, *a, &b)
|
|
112
|
+
# call(s, *a, &b)
|
|
113
|
+
#end
|
|
114
|
+
|
|
115
|
+
def be
|
|
116
|
+
Be.new(@target, @negate)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def not
|
|
120
|
+
Must.new(@target, !@negate)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
#
|
|
126
|
+
class Will < Base
|
|
127
|
+
|
|
128
|
+
def be
|
|
129
|
+
Be.new(@target, @negate)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def not
|
|
133
|
+
Will.new(@target, !@negate)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
#
|
|
139
|
+
class Should < Base
|
|
140
|
+
|
|
141
|
+
#def method_missing(s, *a, &b)
|
|
142
|
+
# call(s, *a, &b)
|
|
143
|
+
#end
|
|
144
|
+
|
|
145
|
+
def be
|
|
146
|
+
Be.new(@target, @negate)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def not
|
|
150
|
+
Should.new(@target, !@negate)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require_relative 'grammar'
|
|
2
|
+
|
|
3
|
+
class Object #BasicObject
|
|
4
|
+
|
|
5
|
+
# Use `is` nomenclature for assertions.
|
|
6
|
+
#
|
|
7
|
+
# 10.is.kind_of?(Integer)
|
|
8
|
+
#
|
|
9
|
+
def is(matcher=nil)
|
|
10
|
+
if matcher
|
|
11
|
+
matcher === self
|
|
12
|
+
else
|
|
13
|
+
::Assay::Fluidity::Grammar::Is.new(self)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require_relative 'grammar'
|
|
2
|
+
|
|
3
|
+
# TODO: What about BasicObject ?
|
|
4
|
+
|
|
5
|
+
class Object #BasicObject
|
|
6
|
+
|
|
7
|
+
# Use `must` nomenclature for assertions.
|
|
8
|
+
#
|
|
9
|
+
# 10.must.be.kind_of(Integer)
|
|
10
|
+
#
|
|
11
|
+
def must(matcher=nil)
|
|
12
|
+
if matcher
|
|
13
|
+
matcher =~ self
|
|
14
|
+
else
|
|
15
|
+
::Assay::Fluidity::Grammar::Must.new(self)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Also, `must_not` nomenclature for assertions.
|
|
20
|
+
#
|
|
21
|
+
# 10.must_not.be.kind_of?(Integer)
|
|
22
|
+
#
|
|
23
|
+
def must_not(matcher=nil)
|
|
24
|
+
if matcher
|
|
25
|
+
matcher !~ self
|
|
26
|
+
else
|
|
27
|
+
::Assay::Fluidity::Grammar::Must.new(self, true)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Contraction do must not.
|
|
32
|
+
#
|
|
33
|
+
# 10.mustnt.be.kind_of?(Integer)
|
|
34
|
+
#
|
|
35
|
+
alias_method :mustnt, :must_not
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require_relative 'grammar'
|
|
2
|
+
|
|
3
|
+
class Object #BasicObject
|
|
4
|
+
|
|
5
|
+
# Use `should` nomenclature for assertions.
|
|
6
|
+
#
|
|
7
|
+
# 10.should.be.kind_of(Integer)
|
|
8
|
+
#
|
|
9
|
+
def should(matcher=nil)
|
|
10
|
+
if matcher
|
|
11
|
+
matcher =~ self
|
|
12
|
+
else
|
|
13
|
+
::Assay::Fluidity::Grammar::Should.new(self)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Also, `should_not` nomenclature for assertions.
|
|
18
|
+
#
|
|
19
|
+
# 10.should_not.be.kind_of?(Integer)
|
|
20
|
+
#
|
|
21
|
+
def should_not(matcher=nil)
|
|
22
|
+
if matcher
|
|
23
|
+
matcher !~ self
|
|
24
|
+
else
|
|
25
|
+
::Assay::Fluidity::Grammar::Should.new(self, true)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
alias_method :shouldnt, :should_not
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require_relative 'grammar'
|
|
2
|
+
|
|
3
|
+
class Object #BasicObject
|
|
4
|
+
|
|
5
|
+
# Use `will` nomenclature for assertions.
|
|
6
|
+
#
|
|
7
|
+
# 10.will.be.kind_of(Integer)
|
|
8
|
+
#
|
|
9
|
+
def will(matcher=nil)
|
|
10
|
+
if matcher
|
|
11
|
+
matcher =~ self
|
|
12
|
+
else
|
|
13
|
+
::Assay::Fluidity::Grammar::Will.new(self)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Also, `will_not` nomenclature for assertions.
|
|
18
|
+
#
|
|
19
|
+
# 10.will_not.be.kind_of?(Integer)
|
|
20
|
+
#
|
|
21
|
+
def will_not(matcher=nil)
|
|
22
|
+
if matcher
|
|
23
|
+
matcher !~ self
|
|
24
|
+
else
|
|
25
|
+
::Assay::Fluidity::Grammar::Will.new(self, true)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Contraction of will not.
|
|
30
|
+
#
|
|
31
|
+
# 10.wont.be.kind_of?(Integer)
|
|
32
|
+
#
|
|
33
|
+
alias_method :wont, :will_not
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
|
data/lib/assay/less_assay.rb
CHANGED