assay 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.rdoc +11 -0
- data/README.rdoc +1 -1
- data/lib/assay/assertion.rb +1 -0
- data/lib/assay/assertions/compare_failure.rb +1 -0
- data/lib/assay/assertions/delta_failure.rb +5 -5
- data/lib/assay/assertions/empty_failure.rb +5 -5
- data/lib/assay/assertions/equality_failure.rb +5 -10
- data/lib/assay/assertions/execution_failure.rb +5 -6
- data/lib/assay/assertions/false_failure.rb +5 -6
- data/lib/assay/assertions/identity_failure.rb +5 -6
- data/lib/assay/assertions/instance_failure.rb +5 -6
- data/lib/assay/assertions/kind_failure.rb +5 -5
- data/lib/assay/assertions/match_failure.rb +5 -6
- data/lib/assay/assertions/nil_failure.rb +5 -5
- data/lib/assay/assertions/raise_failure.rb +2 -1
- data/lib/assay/assertions/response_failure.rb +5 -6
- data/lib/assay/assertions/same_failure.rb +5 -6
- data/lib/assay/assertions/throw_failure.rb +5 -6
- data/lib/assay/assertions/true_failure.rb +5 -6
- metadata +3 -3
data/HISTORY.rdoc
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
= HISTORY
|
2
2
|
|
3
|
+
== 0.3.0 | 2011-05-07
|
4
|
+
|
5
|
+
This release fix the interface of the assertive methods so they accept
|
6
|
+
a message argument, like the original testunit.
|
7
|
+
|
8
|
+
Changes:
|
9
|
+
|
10
|
+
* Fix assertive methods to take message argument.
|
11
|
+
* Fix Assertion class to store message.
|
12
|
+
|
13
|
+
|
3
14
|
== 0.2.0 | 2011-05-05
|
4
15
|
|
5
16
|
This release of Assay is in good working order and can now be used
|
data/README.rdoc
CHANGED
data/lib/assay/assertion.rb
CHANGED
@@ -22,6 +22,7 @@ module Assay
|
|
22
22
|
|
23
23
|
#
|
24
24
|
def to_s
|
25
|
+
return @mesg if @mesg
|
25
26
|
return super unless @arguments.size == 3
|
26
27
|
|
27
28
|
exp = @arguments[0].inspect
|
@@ -43,18 +44,17 @@ module Assay
|
|
43
44
|
#
|
44
45
|
# assert_in_delta 0.05, (50000.0 / 10**6), 0.00001
|
45
46
|
#
|
46
|
-
def assert_in_delta(exp, act, delta,
|
47
|
-
|
48
|
-
DeltaFailure.assert(exp, act, delta, opts)
|
47
|
+
def assert_in_delta(exp, act, delta, msg=nil)
|
48
|
+
DeltaFailure.assert(exp, act, delta, :message=>msg, :backtrace=>caller)
|
49
49
|
end
|
50
50
|
|
51
51
|
# Passes if expected and actual are equal not within delta tolerance.
|
52
52
|
#
|
53
53
|
# assert_not_in_delta 0.05, (50000.0 / 10**6), 0.00001
|
54
54
|
#
|
55
|
-
def self.not_in_delta(exp, act, delta,
|
55
|
+
def self.not_in_delta(exp, act, delta, msg=nil)
|
56
56
|
opts[:backtrace] ||= caller
|
57
|
-
DeltaFailure.refute(exp, act, delta,
|
57
|
+
DeltaFailure.refute(exp, act, delta, :message=>msg, :backtrace=>caller)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -19,6 +19,7 @@ module Assay
|
|
19
19
|
|
20
20
|
#
|
21
21
|
def to_s
|
22
|
+
return @mesg if @mesg
|
22
23
|
return super unless @arguments.size == 1
|
23
24
|
|
24
25
|
exp = @arguments.first.inspect
|
@@ -36,18 +37,17 @@ module Assay
|
|
36
37
|
module Assertives
|
37
38
|
# Passed if object is +true+.
|
38
39
|
#
|
39
|
-
def assert_empty(exp,
|
40
|
-
|
41
|
-
EmptyFailure.assert(exp, opts)
|
40
|
+
def assert_empty(exp, msg=nil)
|
41
|
+
EmptyFailure.assert(exp, :message=>msg, :backtrace=>caller)
|
42
42
|
end
|
43
43
|
|
44
44
|
# Passed if object is not +true+.
|
45
45
|
#
|
46
46
|
# assert_not_true(false)
|
47
47
|
#
|
48
|
-
def refute_empty(exp,
|
48
|
+
def refute_empty(exp, msg=nil)
|
49
49
|
opts[:backtrace] ||= caller
|
50
|
-
EmptyFailure.refute(exp,
|
50
|
+
EmptyFailure.refute(exp, :message=>msg, :backtrace=>caller)
|
51
51
|
end
|
52
52
|
|
53
53
|
alias_method :assert_not_empty, :refute_empty
|
@@ -27,6 +27,7 @@ module Assay
|
|
27
27
|
|
28
28
|
#
|
29
29
|
def to_s
|
30
|
+
return @mesg if @mesg
|
30
31
|
return super unless @arguments.size == 2
|
31
32
|
|
32
33
|
oper = @_negated ? "!=" : "=="
|
@@ -53,22 +54,16 @@ module Assay
|
|
53
54
|
#
|
54
55
|
# assert_equal 'MY STRING', 'my string'.upcase
|
55
56
|
#
|
56
|
-
def assert_equal(exp, act,
|
57
|
-
|
58
|
-
#message = opts[:message]
|
59
|
-
EqualityFailure.assert(exp, act, opts)
|
60
|
-
#err = EqualityFailure.new(message, exp, act)
|
61
|
-
#err.set_backtrace(backtrace)
|
62
|
-
#err.assert(opts)
|
57
|
+
def assert_equal(exp, act, msg=nil)
|
58
|
+
EqualityFailure.assert(exp, act, :message=>msg, :backtrace=>caller)
|
63
59
|
end
|
64
60
|
|
65
61
|
# Passes if expected != actual
|
66
62
|
#
|
67
63
|
# assert_not_equal 'some string', 5
|
68
64
|
#
|
69
|
-
def assert_not_equal(exp, act,
|
70
|
-
|
71
|
-
EqualityFailure.refute(exp, act, opts)
|
65
|
+
def assert_not_equal(exp, act, msg=nil)
|
66
|
+
EqualityFailure.refute(exp, act, :message=>msg, :backtrace=>caller)
|
72
67
|
end
|
73
68
|
end
|
74
69
|
|
@@ -34,6 +34,7 @@ module Assay
|
|
34
34
|
|
35
35
|
#
|
36
36
|
def to_s
|
37
|
+
return @mesg if @mesg
|
37
38
|
if @_negated
|
38
39
|
"Expected procedure to raise an exception"
|
39
40
|
else
|
@@ -51,9 +52,8 @@ module Assay
|
|
51
52
|
# do_the_thing
|
52
53
|
# end
|
53
54
|
#
|
54
|
-
def assert_executes(
|
55
|
-
|
56
|
-
ExecutionFailure.assert(opts, &blk)
|
55
|
+
def assert_executes(msg=nil, &blk)
|
56
|
+
ExecutionFailure.assert(:message=>msg, :backtrace=>caller, &blk)
|
57
57
|
end
|
58
58
|
|
59
59
|
# Passes if the block does not yield successfully.
|
@@ -62,9 +62,8 @@ module Assay
|
|
62
62
|
# do_the_thing
|
63
63
|
# end
|
64
64
|
#
|
65
|
-
def assert_not_executes(
|
66
|
-
|
67
|
-
ExecutionFailure.refute(opts, &blk)
|
65
|
+
def assert_not_executes(msg=nil, &blk)
|
66
|
+
ExecutionFailure.refute(:message=>msg, :backtrace=>caller, &blk)
|
68
67
|
end
|
69
68
|
end
|
70
69
|
|
@@ -19,6 +19,7 @@ module Assay
|
|
19
19
|
|
20
20
|
#
|
21
21
|
def to_s
|
22
|
+
return @mesg if @mesg
|
22
23
|
return super unless @arguments.size == 1
|
23
24
|
|
24
25
|
exp = @arguments[0].inspect
|
@@ -36,18 +37,16 @@ module Assay
|
|
36
37
|
module Assertives
|
37
38
|
# Passed if object is +false+.
|
38
39
|
#
|
39
|
-
def assert_false(exp,
|
40
|
-
|
41
|
-
FalseFailure.assert(exp, opts)
|
40
|
+
def assert_false(exp, msg=nil)
|
41
|
+
FalseFailure.assert(exp, :message=>msg, :backtrace=>caller)
|
42
42
|
end
|
43
43
|
|
44
44
|
# Passed if object is not +false+.
|
45
45
|
#
|
46
46
|
# assert_not_false(false)
|
47
47
|
#
|
48
|
-
def assert_not_false(exp,
|
49
|
-
|
50
|
-
FalseFailure.refute(exp, opts)
|
48
|
+
def assert_not_false(exp, msg=nil)
|
49
|
+
FalseFailure.refute(exp, :message=>msg, :backtrace=>caller)
|
51
50
|
end
|
52
51
|
end
|
53
52
|
|
@@ -27,6 +27,7 @@ module Assay
|
|
27
27
|
|
28
28
|
#
|
29
29
|
def to_s
|
30
|
+
return @mesg if @mesg
|
30
31
|
return super unless @arguments.size == 2
|
31
32
|
|
32
33
|
iexp = @arguments[0].inspect
|
@@ -48,18 +49,16 @@ module Assay
|
|
48
49
|
# o = Object.new
|
49
50
|
# assert_identical(o, o)
|
50
51
|
#
|
51
|
-
def assert_identical(exp, act,
|
52
|
-
|
53
|
-
IdentityFailure.assert(exp, act, opts)
|
52
|
+
def assert_identical(exp, act, msg=nil)
|
53
|
+
IdentityFailure.assert(exp, act, :message=>msg, :backtrace=>caller)
|
54
54
|
end
|
55
55
|
|
56
56
|
# Passes if ! actual .equal? expected
|
57
57
|
#
|
58
58
|
# assert_not_identical(Object.new, Object.new)
|
59
59
|
#
|
60
|
-
def assert_not_identical(exp, act,
|
61
|
-
|
62
|
-
IdentityFailure.refute(exp, act, opts)
|
60
|
+
def assert_not_identical(exp, act, msg=nil)
|
61
|
+
IdentityFailure.refute(exp, act, :message=>msg, :backtrace=>caller)
|
63
62
|
end
|
64
63
|
end
|
65
64
|
|
@@ -19,6 +19,7 @@ module Assay
|
|
19
19
|
|
20
20
|
#
|
21
21
|
def to_s
|
22
|
+
return @mesg if @mesg
|
22
23
|
return super unless @arguments.size == 2
|
23
24
|
|
24
25
|
exp = @arguments[0].inspect
|
@@ -38,18 +39,16 @@ module Assay
|
|
38
39
|
#
|
39
40
|
# assert_instance_of(String, 'foo')
|
40
41
|
#
|
41
|
-
def assert_instance_of(cls, obj,
|
42
|
-
|
43
|
-
InstanceFailure.assert(cls, obj, opts)
|
42
|
+
def assert_instance_of(cls, obj, msg=nil)
|
43
|
+
InstanceFailure.assert(cls, obj, :message=>msg, :backtrace=>caller)
|
44
44
|
end
|
45
45
|
|
46
46
|
# Passes if object .instance_of? klass
|
47
47
|
#
|
48
48
|
# assert_instance_of(String, 'foo')
|
49
49
|
#
|
50
|
-
def refute_instance_of(cls, obj,
|
51
|
-
|
52
|
-
InstanceFailure.refute(cls, obj, opts)
|
50
|
+
def refute_instance_of(cls, obj, msg=nil)
|
51
|
+
InstanceFailure.refute(cls, obj, :message=>msg, :backtrace=>caller)
|
53
52
|
end
|
54
53
|
|
55
54
|
alias_method :assert_not_instance_of, :refute_instance_of
|
@@ -24,6 +24,7 @@ module Assay
|
|
24
24
|
|
25
25
|
#
|
26
26
|
def to_s
|
27
|
+
return @mesg if @mesg
|
27
28
|
return super unless @arguments.size == 2
|
28
29
|
|
29
30
|
exp = @arguments[0].inspect
|
@@ -43,17 +44,16 @@ module Assay
|
|
43
44
|
#
|
44
45
|
# assert_kind_of(Object, 'foo')
|
45
46
|
#
|
46
|
-
def assert_kind_of(cls, obj,
|
47
|
-
|
48
|
-
KindFailure.assert(cls, obj, opts)
|
47
|
+
def assert_kind_of(cls, obj, msg=nil)
|
48
|
+
KindFailure.assert(cls, obj, :message=>msg, :backtrace=>caller)
|
49
49
|
end
|
50
50
|
|
51
51
|
# Passes if object .kind_of? klass
|
52
52
|
#
|
53
53
|
# assert_not_kind_of(Object, 'foo')
|
54
54
|
#
|
55
|
-
def refute_kind_of(cls, obj,
|
56
|
-
KindFailure.refute(cls, obj,
|
55
|
+
def refute_kind_of(cls, obj, msg=nil)
|
56
|
+
KindFailure.refute(cls, obj, :message=>msg, :backtrace=>caller)
|
57
57
|
end
|
58
58
|
alias_method :assert_not_kind_of, :refute_kind_of
|
59
59
|
end
|
@@ -29,6 +29,7 @@ module Assay
|
|
29
29
|
|
30
30
|
#
|
31
31
|
def to_s
|
32
|
+
return @mesg if @mesg
|
32
33
|
return super unless @arguments.size == 2
|
33
34
|
|
34
35
|
exp = @arguments[0].inspect
|
@@ -49,18 +50,16 @@ module Assay
|
|
49
50
|
#
|
50
51
|
# assert_match(/\d+/, 'five, 6, seven')
|
51
52
|
#
|
52
|
-
def assert_match(exp, act,
|
53
|
-
|
54
|
-
MatchFailure.assert(exp, act, opts)
|
53
|
+
def assert_match(exp, act, msg=nil)
|
54
|
+
MatchFailure.assert(exp, act, :message=>msg, :backtrace=>caller)
|
55
55
|
end
|
56
56
|
|
57
57
|
# Passes if regexp !~ string
|
58
58
|
#
|
59
59
|
# refute_match(/two/, 'one 2 three')
|
60
60
|
#
|
61
|
-
def refute_match(exp, act,
|
62
|
-
|
63
|
-
MatchFailure.refute(exp, act, opts)
|
61
|
+
def refute_match(exp, act, msg=nil)
|
62
|
+
MatchFailure.refute(exp, act, :message=>msg, :backtrace=>caller)
|
64
63
|
end
|
65
64
|
end
|
66
65
|
|
@@ -19,6 +19,7 @@ module Assay
|
|
19
19
|
|
20
20
|
#
|
21
21
|
def to_s
|
22
|
+
return @mesg if @mesg
|
22
23
|
return super unless @arguments.size == 1
|
23
24
|
|
24
25
|
exp = @arguments[0].inspect
|
@@ -36,18 +37,17 @@ module Assay
|
|
36
37
|
module Assertives
|
37
38
|
# Passed if object is +nil+.
|
38
39
|
#
|
39
|
-
def assert_nil(exp,
|
40
|
-
|
41
|
-
NilFailure.assert(exp, opts)
|
40
|
+
def assert_nil(exp, msg=nil)
|
41
|
+
NilFailure.assert(exp, :message=>msg, :backtrace=>caller)
|
42
42
|
end
|
43
43
|
|
44
44
|
# Passed if object is not +nil+.
|
45
45
|
#
|
46
46
|
# assert_not_nil(true)
|
47
47
|
#
|
48
|
-
def assert_not_nil(exp,
|
48
|
+
def assert_not_nil(exp, msg=nil)
|
49
49
|
opts[:backtrace] ||= caller
|
50
|
-
NilFailure.refute(exp,
|
50
|
+
NilFailure.refute(exp, :message=>msg, :backtrace=>caller)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -74,6 +74,7 @@ module Assay
|
|
74
74
|
|
75
75
|
# TODO: how to add `but got class` instead.
|
76
76
|
def to_s
|
77
|
+
return @mesg if @mesg
|
77
78
|
return super unless @arguments.size == 1
|
78
79
|
|
79
80
|
exp = @arguments[0].inspect
|
@@ -90,7 +91,7 @@ module Assay
|
|
90
91
|
|
91
92
|
|
92
93
|
module Assertives
|
93
|
-
# Passes if the block raises a given
|
94
|
+
# Passes if the block raises a given exception.
|
94
95
|
#
|
95
96
|
# assert_raises RuntimeError do
|
96
97
|
# raise 'Boom!!!'
|
@@ -26,6 +26,7 @@ module Assay
|
|
26
26
|
|
27
27
|
#
|
28
28
|
def to_s
|
29
|
+
return @mesg if @mesg
|
29
30
|
return super unless @arguments.size == 2
|
30
31
|
|
31
32
|
reciever = @arguments[0].inspect
|
@@ -46,9 +47,8 @@ module Assay
|
|
46
47
|
#
|
47
48
|
# assert_respond_to 'bugbear', :slice
|
48
49
|
#
|
49
|
-
def assert_respond_to(reciever, method,
|
50
|
-
|
51
|
-
ResponseFailure.assert(reciever, method, opts)
|
50
|
+
def assert_respond_to(reciever, method, msg=nil)
|
51
|
+
ResponseFailure.assert(reciever, method, :message=>msg, :backtrace=>caller)
|
52
52
|
end
|
53
53
|
alias_method :assert_responds_to, :assert_respond_to
|
54
54
|
|
@@ -56,9 +56,8 @@ module Assay
|
|
56
56
|
#
|
57
57
|
# assert_not_respond_to 'bugbear', :slice
|
58
58
|
#
|
59
|
-
def assert_not_respond_to(reciever, method,
|
60
|
-
|
61
|
-
ResponseFailure.refute(reciever, method, opts)
|
59
|
+
def assert_not_respond_to(reciever, method, msg=nil)
|
60
|
+
ResponseFailure.refute(reciever, method, :message=>msg, :backtrace=>caller)
|
62
61
|
end
|
63
62
|
|
64
63
|
alias_method :assert_not_responds_to, :assert_not_respond_to
|
@@ -20,6 +20,7 @@ module Assay
|
|
20
20
|
|
21
21
|
#
|
22
22
|
def to_s
|
23
|
+
return @mesg if @mesg
|
23
24
|
return super unless @arguments.size == 2
|
24
25
|
|
25
26
|
exp = @arguments[0].inspect
|
@@ -44,18 +45,16 @@ module Assay
|
|
44
45
|
#
|
45
46
|
# assert_same 'MY STRING', 'my string'.upcase
|
46
47
|
#
|
47
|
-
def assert_same(exp, act,
|
48
|
-
|
49
|
-
SameFailure.assert(exp, act, opts)
|
48
|
+
def assert_same(exp, act, msg=nil)
|
49
|
+
SameFailure.assert(exp, act, :message=>msg, :backtrace=>caller)
|
50
50
|
end
|
51
51
|
|
52
52
|
# Passes if not +expected+ .eq? +actual+.
|
53
53
|
#
|
54
54
|
# assert_not_the_same 'some string', 5
|
55
55
|
#
|
56
|
-
def refute_same(exp, act,
|
57
|
-
|
58
|
-
SameFailure.refute(exp, act, opts)
|
56
|
+
def refute_same(exp, act, msg=nil)
|
57
|
+
SameFailure.refute(exp, act, :message=>msg, :backtrace=>caller)
|
59
58
|
end
|
60
59
|
|
61
60
|
alias_method :assert_not_same, :refute_same
|
@@ -60,6 +60,7 @@ module Assay
|
|
60
60
|
|
61
61
|
#
|
62
62
|
def to_s
|
63
|
+
return @mesg if @mesg
|
63
64
|
return super unless @arguments.size == 1
|
64
65
|
|
65
66
|
sym = @arguments[0].inspect
|
@@ -81,9 +82,8 @@ module Assay
|
|
81
82
|
# throw :done
|
82
83
|
# end
|
83
84
|
#
|
84
|
-
def assert_throws(sym,
|
85
|
-
|
86
|
-
ThrowFailure.assert(sym, opts, &blk)
|
85
|
+
def assert_throws(sym, msg=nil, &blk)
|
86
|
+
ThrowFailure.assert(sym, :message=>msg, :backtrace=>caller, &blk)
|
87
87
|
end
|
88
88
|
|
89
89
|
# Passes if the block throws expected_symbol
|
@@ -92,9 +92,8 @@ module Assay
|
|
92
92
|
# throw :chimp
|
93
93
|
# end
|
94
94
|
#
|
95
|
-
def refute_throws(sym,
|
96
|
-
|
97
|
-
ThrowFailure.refute(sym, opts, &blk)
|
95
|
+
def refute_throws(sym, msg=nil, &blk)
|
96
|
+
ThrowFailure.refute(sym, :message=>msg, :backtrace=>caller, &blk)
|
98
97
|
end
|
99
98
|
|
100
99
|
alias_method :assert_not_thrown, :refute_throws
|
@@ -25,6 +25,7 @@ module Assay
|
|
25
25
|
|
26
26
|
#
|
27
27
|
def to_s
|
28
|
+
return @mesg if @mesg
|
28
29
|
return super unless @arguments.size == 1
|
29
30
|
|
30
31
|
exp = @arguments[0].inspect
|
@@ -42,18 +43,16 @@ module Assay
|
|
42
43
|
module Assertives
|
43
44
|
# Passed if object is +true+.
|
44
45
|
#
|
45
|
-
def assert_true(exp,
|
46
|
-
|
47
|
-
TrueFailure.assert(exp, opts)
|
46
|
+
def assert_true(exp, msg=nil)
|
47
|
+
TrueFailure.assert(exp, :message=>msg, :backtrace=>caller)
|
48
48
|
end
|
49
49
|
|
50
50
|
# Passed if object is not +true+.
|
51
51
|
#
|
52
52
|
# assert_not_true(false)
|
53
53
|
#
|
54
|
-
def assert_not_true(exp,
|
55
|
-
|
56
|
-
TrueFailure.refute(exp, opts)
|
54
|
+
def assert_not_true(exp, msg=nil)
|
55
|
+
TrueFailure.refute(exp, :message=>msg, :backtrace=>caller)
|
57
56
|
end
|
58
57
|
end
|
59
58
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: assay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 3
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Thomas Sawyer
|