fun_with_testing 0.0.4 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/CHANGELOG.markdown +27 -0
- data/Gemfile +21 -10
- data/Rakefile +22 -6
- data/VERSION +1 -1
- data/lib/fun_with/testing/assertions/basics.rb +216 -139
- data/lib/fun_with/testing/assertions_test_case.rb +65 -0
- data/lib/fun_with/testing/test_case.rb +9 -57
- data/lib/fun_with/testing/test_mode_methods.rb +32 -0
- data/lib/fun_with/testing/verbosity_methods.rb +43 -0
- data/lib/fun_with_testing.rb +15 -9
- data/test/helper.rb +1 -30
- data/test/test_assertions.rb +578 -14
- data/test/test_fun_with_testing.rb +0 -3
- data/test/test_test_mode.rb +29 -28
- data/test/test_verbosity.rb +2 -1
- metadata +91 -45
- data/lib/fun_with/testing/assertions/active_record.rb +0 -108
- data/lib/fun_with/testing/assertions/fun_with_files.rb +0 -109
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MmI0Nzg3YzUzYmRjMGE5MzUzN2ZkNmVhODMyZWJmOTM2ZGJjYmI0Mw==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: eb64dd009618bda745cdfab2c2aec0a6b211bb8b
|
4
|
+
data.tar.gz: 9bd5755ded13b000d9d8f0eb456cd991f9c09eba
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
ZGQ5ODJhMzc0NTZiYjZhNTI1NGExYzk4NDJjODkwZjQ3M2QzYzFlNDRiYTBh
|
11
|
-
NjM0YTA5NzVmMDE5YTc3ZGQ3YmQ0ZGJhMTQyMGIwM2QxY2FlNGE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MzIyZDJiMWIxNmU3MWM5NjM4Njk5NmEyYTJkOTVlZDYyMjU2NWM4Y2NhM2Nk
|
14
|
-
OWZkYTRkZjA0NGM0YzQ3MWEyMTI5NTExYzMzMGYzZTNhODc1NDkxYTIyZjk5
|
15
|
-
NmI1MTA3YjczNDJlZjAwNDc3YzBiYzg4MDVjMmFlODlkYTNkZGQ=
|
6
|
+
metadata.gz: d0cfca949bcf3c2c20f4b60bd406ac6b7fc50697c8ecf059190d5840b5e0a499c1398cc3cec78e16aa32c5a747202ba28adaa4a410d9099350fd7440c3978cb9
|
7
|
+
data.tar.gz: b8c7fc8602da5dfd3632134384beb29243bd873dc65af3b2662a2bb798b1159fae691ea7259236cf70095b9c2dd44219c9cebc78d7ba7b7a55938d364ee427ba
|
data/CHANGELOG.markdown
CHANGED
@@ -1,6 +1,33 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
=========
|
3
3
|
|
4
|
+
v0.0.?+
|
5
|
+
------
|
6
|
+
|
7
|
+
|
8
|
+
v0.0.8
|
9
|
+
-------
|
10
|
+
|
11
|
+
* Moving TestMode and Verbosity stuff into FunWith::Gems? Can be used to install "test mode" and "verbosity" on any object/module/class?
|
12
|
+
|
13
|
+
v0.0.7 (current)
|
14
|
+
-----------------
|
15
|
+
|
16
|
+
* Moving everything related to FunWith::Files into that gem.
|
17
|
+
* Removing ActiveRecord stuff in preparation for Glorious FunWith::Rails Future!
|
18
|
+
|
19
|
+
v0.0.6
|
20
|
+
------
|
21
|
+
|
22
|
+
* Adding meat to the testing section
|
23
|
+
* (Temporarily?) dropping the illusion of Ruby < 2.0 support
|
24
|
+
|
25
|
+
|
26
|
+
v0.0.5
|
27
|
+
------
|
28
|
+
|
29
|
+
????? - not inspiring confidence here
|
30
|
+
|
4
31
|
v0.0.4
|
5
32
|
------
|
6
33
|
|
data/Gemfile
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
|
+
|
2
3
|
# Add dependencies required to use your gem here.
|
3
4
|
# Example:
|
4
5
|
# gem "activesupport", ">= 2.3.5"
|
@@ -9,17 +10,27 @@ group :development do
|
|
9
10
|
# gem "shoulda", "~> 3", ">= 3.5"
|
10
11
|
# gem "rdoc", "~> 3.12"
|
11
12
|
# gem "bundler", "~> 1.0"
|
12
|
-
# gem "
|
13
|
-
# # gem "rcov", ">= 0"
|
13
|
+
# gem "rcov", ">= 0"
|
14
14
|
# gem 'debugger', "~> 1.6"
|
15
15
|
# gem 'minitest'
|
16
|
+
# gem "fun_with_testing", "~> 0.0", ">= 0.0.4"
|
17
|
+
end
|
18
|
+
|
19
|
+
# Bundler keeps trying to install rack 2,
|
20
|
+
# failing because it requires Ruby 2.2 or higher
|
21
|
+
|
22
|
+
ruby_major, ruby_minor, ruby_patch = RUBY_VERSION.split(".").map(&:to_i)
|
23
|
+
|
24
|
+
if ruby_major < 2 || ruby_minor < 2 || ruby_minor == 2 && ruby_patch <= 1
|
25
|
+
gem "rack", "~> 1"
|
26
|
+
else
|
27
|
+
gem "rack", "~> 2"
|
16
28
|
end
|
17
29
|
|
18
|
-
gem "shoulda",
|
19
|
-
gem "rdoc",
|
20
|
-
gem "bundler",
|
21
|
-
gem "
|
22
|
-
|
23
|
-
gem
|
24
|
-
gem '
|
25
|
-
gem 'minitest', "~> 5"
|
30
|
+
gem "shoulda", "~> 3", ">= 3.5"
|
31
|
+
gem "rdoc", "~> 4", ">= 4.2.2"
|
32
|
+
gem "bundler", "~> 1", ">= 1.10"
|
33
|
+
gem "juwelier", "~> 2", ">= 2.1"
|
34
|
+
gem "simplecov", "~> 0", ">= 0.11"
|
35
|
+
gem 'byebug', "~> 9", ">= 9.0"
|
36
|
+
gem 'minitest', "~> 5", ">= 5.9"
|
data/Rakefile
CHANGED
@@ -11,24 +11,32 @@ rescue Bundler::BundlerError => e
|
|
11
11
|
end
|
12
12
|
require 'rake'
|
13
13
|
|
14
|
-
require '
|
15
|
-
|
14
|
+
require 'juwelier'
|
15
|
+
Juwelier::Tasks.new do |gem|
|
16
16
|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
17
|
gem.name = "fun_with_testing"
|
18
|
+
|
19
|
+
# TODO: Not holding up rake-install, as best I can tell. Delete line?
|
20
|
+
# gem.version = (File.exist?('VERSION') ? File.read('VERSION') : "0.0.0")
|
21
|
+
|
22
|
+
|
18
23
|
gem.homepage = "http://github.com/darthschmoo/fun_with_testing"
|
19
|
-
gem.
|
24
|
+
gem.licenses = ["MIT"]
|
20
25
|
gem.summary = "A place to stash Test::Unit assertions I've found handy."
|
21
26
|
gem.description = "A place to stash Test::Unit assertions I've found handy. Use at your own risk"
|
22
27
|
gem.email = "keeputahweird@gmail.com"
|
23
28
|
gem.authors = ["Bryce Anderson"]
|
24
29
|
|
25
|
-
|
30
|
+
# Tried getting rid of this to see if it was blocking rake-install.
|
31
|
+
# No surch lurx.
|
32
|
+
gem.files = Dir.glob( File.join( ".", "lib", "**", "*.rb" ) ) +
|
26
33
|
Dir.glob( File.join( ".", "test", "**", "*" ) ) +
|
27
34
|
%w( Gemfile Rakefile LICENSE.txt README.rdoc VERSION CHANGELOG.markdown )
|
28
|
-
|
35
|
+
|
29
36
|
# dependencies defined in Gemfile
|
30
37
|
end
|
31
|
-
|
38
|
+
|
39
|
+
Juwelier::RubygemsDotOrgTasks.new
|
32
40
|
|
33
41
|
require 'rake/testtask'
|
34
42
|
Rake::TestTask.new(:test) do |test|
|
@@ -45,6 +53,14 @@ end
|
|
45
53
|
# test.rcov_opts << '--exclude "gems/*"'
|
46
54
|
# end
|
47
55
|
|
56
|
+
# Adding this to see if it's making any difference
|
57
|
+
desc "Code coverage detail"
|
58
|
+
task :simplecov do
|
59
|
+
ENV['COVERAGE'] = "true"
|
60
|
+
Rake::Task['test'].execute
|
61
|
+
end
|
62
|
+
|
63
|
+
|
48
64
|
task :default => :test
|
49
65
|
|
50
66
|
require 'rdoc/task'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.7
|
@@ -2,197 +2,274 @@ module FunWith
|
|
2
2
|
module Testing
|
3
3
|
module Assertions
|
4
4
|
module Basics
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
# Interesting thing about message() : returns a proc that, when called, returns
|
6
|
+
# the message string. I don't quite understand why it's done that way, but
|
7
|
+
# to add a line to an existing msg proc, do `msg = message(msg){"line to add..."}`
|
8
|
+
|
9
|
+
def assert_not_zero( actual, msg = nil )
|
10
|
+
msg = message(msg) { "Expected #{mu_pp(actual)} to not be zero" }
|
11
|
+
assert actual != 0, msg
|
12
|
+
end
|
13
|
+
|
14
|
+
alias :refute_zero :assert_not_zero
|
15
|
+
|
16
|
+
def assert_zero( actual, msg = nil )
|
17
|
+
msg = message(msg) { "should be zero, not <#{mu_pp(actual)}>" }
|
18
|
+
assert actual == 0, msg
|
11
19
|
end
|
12
20
|
|
13
|
-
def
|
14
|
-
|
21
|
+
def assert_one( actual, msg = nil )
|
22
|
+
msg = message(msg) { "should be 1, not <#{mu_pp(actual)}>" }
|
23
|
+
assert actual == 1, msg
|
24
|
+
end
|
25
|
+
|
26
|
+
def assert_not_one( actual, msg = nil )
|
27
|
+
msg = message(msg) { "should be 1, not <#{mu_pp(actual)}>" }
|
28
|
+
assert actual != 1, msg
|
29
|
+
end
|
30
|
+
|
31
|
+
alias :refute_one :assert_not_one
|
32
|
+
|
33
|
+
def assert_negative( actual, msg = nil )
|
34
|
+
msg = message(msg) { "should be negative, not <#{mu_pp(actual)}>" }
|
35
|
+
assert actual < 0, msg
|
36
|
+
end
|
15
37
|
|
16
|
-
|
17
|
-
|
18
|
-
|
38
|
+
def assert_not_negative( actual, msg = nil )
|
39
|
+
msg = message(msg) { "should NOT be negative, (actual) <#{mu_pp(actual)}>" }
|
40
|
+
assert actual >= 0, msg
|
19
41
|
end
|
42
|
+
|
43
|
+
alias :refute_negative :assert_not_negative
|
20
44
|
|
21
|
-
def
|
22
|
-
|
45
|
+
def assert_positive( actual, msg = nil )
|
46
|
+
msg = message(msg) { "should be positive, not <#{mu_pp(actual)}>" }
|
47
|
+
assert actual > 0, msg
|
48
|
+
end
|
23
49
|
|
24
|
-
|
25
|
-
|
26
|
-
|
50
|
+
def assert_not_positive( actual, msg = nil )
|
51
|
+
msg = message(msg) { "should NOT be positive, (actual) <#{mu_pp(actual)}>" }
|
52
|
+
assert actual <= 0, msg
|
27
53
|
end
|
28
54
|
|
29
|
-
|
30
|
-
message = build_message(message, "should be negative, not <#{actual}>")
|
55
|
+
alias :refute_positive :assert_not_positive
|
31
56
|
|
32
|
-
|
33
|
-
|
34
|
-
|
57
|
+
def assert_true( actual, msg = nil )
|
58
|
+
msg = message(msg) { "should be true (TrueClass), not <#{mu_pp(actual)}>" }
|
59
|
+
assert actual == true, msg
|
35
60
|
end
|
36
61
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
62
|
+
def refute_true( actual, msg = nil )
|
63
|
+
msg = message(msg) { "shouldn't be true (TrueClass)" }
|
64
|
+
assert actual != true, msg
|
65
|
+
end
|
66
|
+
|
67
|
+
# rejects anything but an actual false, instance of the FalseClass
|
68
|
+
def assert_false( actual, msg = nil )
|
69
|
+
msg = message(msg) { "should be false (instance of FalseClass), not <#{mu_pp(actual)}>" }
|
70
|
+
assert actual == false, msg
|
42
71
|
end
|
43
72
|
|
44
|
-
def
|
45
|
-
|
46
|
-
|
47
|
-
actual == false
|
48
|
-
end
|
73
|
+
def refute_false( actual, msg = nil )
|
74
|
+
msg = message(msg) { "shouldn't be false" }
|
75
|
+
assert actual != false, msg
|
49
76
|
end
|
50
77
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
safe_assert_block message do
|
55
|
-
actual == nil
|
56
|
-
end
|
78
|
+
def assert_nil( actual, msg = nil )
|
79
|
+
msg = message(msg) { "should be nil, not <#{mu_pp(actual)}>" }
|
80
|
+
assert actual == nil, msg
|
57
81
|
end
|
58
82
|
|
59
|
-
def assert_not_nil( actual,
|
60
|
-
|
61
|
-
|
62
|
-
actual != nil
|
63
|
-
end
|
83
|
+
def assert_not_nil( actual, msg = nil )
|
84
|
+
msg = message(msg) { "should not be nil" }
|
85
|
+
assert actual != nil, msg
|
64
86
|
end
|
65
87
|
|
66
88
|
alias :refute_nil :assert_not_nil
|
67
89
|
|
68
|
-
def
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
full_message = build_message(message, "<?> does not respond to :blank? method.", obj)
|
73
|
-
end
|
90
|
+
def assert_responds_to_blank( obj, message = nil )
|
91
|
+
msg = message(msg){
|
92
|
+
"<#{mu_pp(obj)}> does not respond to :blank? or :fwf_blank? methods."
|
93
|
+
}
|
74
94
|
|
75
|
-
|
76
|
-
obj.respond_to?(:blank?) && obj.blank?
|
77
|
-
end
|
95
|
+
assert obj.respond_to?(:blank?) || obj.respond_to?( :fwf_blank? ), msg
|
78
96
|
end
|
79
|
-
|
80
|
-
def
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
string.include?(regexp_or_string)
|
87
|
-
end
|
88
|
-
end
|
97
|
+
|
98
|
+
def assert_blank( obj, msg = nil )
|
99
|
+
assert_responds_to_blank( obj )
|
100
|
+
|
101
|
+
msg = message(msg) { "#{mu_pp(obj)} should be blank." }
|
102
|
+
|
103
|
+
assert( (obj.respond_to?(:blank?) && obj.blank?) || (obj.respond_to?(:fwf_blank?) && obj.fwf_blank?), msg )
|
89
104
|
end
|
90
105
|
|
91
|
-
def
|
92
|
-
|
93
|
-
|
94
|
-
|
106
|
+
def assert_matches( string, regexp_or_string, msg = nil)
|
107
|
+
msg = message(msg) { "<#{mu_pp(string)}> should match regex <#{mu_pp(regexp_or_string)}>" }
|
108
|
+
|
109
|
+
if regexp_or_string.is_a?(Regexp)
|
110
|
+
assert string.match(regexp_or_string), msg
|
111
|
+
elsif regexp_or_string.is_a?(String)
|
112
|
+
assert string.include?(regexp_or_string), msg
|
113
|
+
else
|
114
|
+
raise ArgumentError.new( "assert_matches takes a regular expression or string as second argument, not #{regexp_or_string}(#{regexp_or_string.class})")
|
95
115
|
end
|
116
|
+
|
117
|
+
true
|
96
118
|
end
|
97
119
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
# or
|
106
|
-
# order = assert_assigns(:order)
|
107
|
-
def assert_assigns(*args)
|
108
|
-
symbols_assigned = []
|
109
|
-
symbols_not_assigned = []
|
110
|
-
|
111
|
-
for sym in args
|
112
|
-
((assigns(sym) != nil)? symbols_assigned : symbols_not_assigned) << sym
|
113
|
-
end
|
114
|
-
|
115
|
-
message = build_message("", "The following variables should have been assigned values by the controller: <?>", symbols_not_assigned.map{|s| "@#{s.to_s}"}.join(", "))
|
116
|
-
|
117
|
-
safe_assert_block message do
|
118
|
-
symbols_not_assigned.length == 0
|
119
|
-
end
|
120
|
-
|
121
|
-
if symbols_assigned.length == 1
|
122
|
-
assigns(symbols_assigned.first)
|
120
|
+
def assert_doesnt_match( string, regexp_or_string, msg = nil)
|
121
|
+
msg = message(msg) { "<#{mu_pp(string)}> should NOT match string/regex <#{mu_pp(regexp_or_string)}>" }
|
122
|
+
|
123
|
+
if regexp_or_string.is_a?(Regexp)
|
124
|
+
assert_nil string.match(regexp_or_string), msg
|
125
|
+
elsif regexp_or_string.is_a?(String)
|
126
|
+
refute string.include?(regexp_or_string), msg
|
123
127
|
else
|
124
|
-
|
128
|
+
raise ArgumentError.new( "assert_doesnt_match takes a regular expression or string as second argument, not #{regexp_or_string}(#{regexp_or_string.class})")
|
125
129
|
end
|
130
|
+
|
131
|
+
true
|
126
132
|
end
|
133
|
+
|
134
|
+
alias :refute_matches :assert_doesnt_match
|
127
135
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
136
|
+
|
137
|
+
def assert_greater_than( reference_value, amount, msg = nil )
|
138
|
+
msg = message(msg){
|
139
|
+
"second argument <#{mu_pp(amount)}> should be greater than reference value <#{mu_pp(reference_value)}>"
|
140
|
+
}
|
132
141
|
|
133
|
-
|
134
|
-
amount > reference_value
|
135
|
-
end
|
142
|
+
assert amount > reference_value, msg
|
136
143
|
end
|
137
144
|
|
138
145
|
# read as "assert less than 5, <test value>"
|
139
|
-
def assert_less_than( reference_value, amount,
|
140
|
-
|
146
|
+
def assert_less_than( reference_value, amount, msg = nil )
|
147
|
+
msg = message(msg){
|
148
|
+
"second argument <#{mu_pp(amount)} should be less than reference value <#{mu_pp(reference_value)}>"
|
149
|
+
}
|
141
150
|
|
142
|
-
|
143
|
-
amount < reference_value
|
144
|
-
end
|
151
|
+
assert amount < reference_value, msg
|
145
152
|
end
|
146
153
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
+
def assert_at_least( reference_value, amount, msg = nil )
|
155
|
+
msg = message(msg) { "Value must be at least #{reference_value}. #{mu_pp(amount)} is too small." }
|
156
|
+
|
157
|
+
assert( amount >= reference_value, msg )
|
158
|
+
end
|
159
|
+
|
160
|
+
def assert_at_most( reference_value, amount, msg = nil )
|
161
|
+
msg = message(msg) { "Value can be at most #{reference_value}. #{mu_pp(amount)} is too large." }
|
162
|
+
|
163
|
+
assert( amount <= reference_value, msg )
|
164
|
+
end
|
165
|
+
|
166
|
+
# I think "assert_delta_in_range" already does this for floats
|
167
|
+
def assert_times_are_close( t1, t2, window = 1, msg = nil)
|
168
|
+
msg = message(msg) { "times should be within #{mu_pp(window)} second of each other." }
|
169
|
+
assert (t1 - t2).abs <= window
|
154
170
|
end
|
155
171
|
|
156
|
-
def assert_equal_length( expected, actual,
|
157
|
-
|
172
|
+
def assert_equal_length( expected, actual, msg = nil )
|
173
|
+
assert_respond_to expected, :length, message(nil){ "#{mu_pp(expected)} (expected value) doesn't respond to length()." }
|
174
|
+
assert_respond_to actual, :length, message(nil){ "#{mu_pp(actual)} (actual value) doesn't respond to length()." }
|
175
|
+
|
176
|
+
msg = message(msg){
|
177
|
+
"items should be of equal length: expected length: <#{mu_pp(expected.length)}>, actual length: <#{mu_pp(actual.length)}>"
|
178
|
+
}
|
179
|
+
|
180
|
+
assert_equal expected.length, actual.length, msg
|
181
|
+
end
|
182
|
+
|
183
|
+
def assert_unequal_length( expected, actual, msg = nil )
|
184
|
+
msg = message(msg){
|
185
|
+
"items should be of equal length: expected: <#{mu_pp(expected.length)}>, actual: <#{mu_pp(actual.length)}>"
|
186
|
+
}
|
187
|
+
|
188
|
+
assert_respond_to expected, :length, message(nil){ "#{mu_pp(expected)} (expected value) doesn't respond to length()." }
|
189
|
+
assert_respond_to actual, :length, message(nil){ "#{mu_pp(actual)} (actual value) doesn't respond to length()." }
|
190
|
+
|
191
|
+
assert_equal expected.length, actual.length, message
|
192
|
+
end
|
193
|
+
|
194
|
+
alias :refute_equal_length :assert_unequal_length
|
195
|
+
|
196
|
+
|
197
|
+
# `expected` can be a numeric range
|
198
|
+
def assert_length( expected, actual, msg = nil )
|
199
|
+
|
200
|
+
no_response_msg = message(nil){ "<#{mu_pp(actual)}> doesn't respond to .length()" }
|
158
201
|
|
159
|
-
|
160
|
-
|
202
|
+
assert_respond_to actual, :length, no_response_msg
|
203
|
+
|
204
|
+
case expected
|
205
|
+
when Range
|
206
|
+
msg = message(msg){
|
207
|
+
"<#{mu_pp(actual)}> has a length of #{mu_pp(actual.length)}. Length must be between <#{mu_pp(expected.min)}> and <#{mu_pp(expected.max)}>"
|
208
|
+
}
|
209
|
+
|
210
|
+
assert_at_least expected.min, actual.length, msg
|
211
|
+
assert_at_most expected.max, actual.length, msg
|
212
|
+
when Integer
|
213
|
+
msg = message(msg){ "<#{mu_pp(actual)}> has a length of <#{mu_pp(actual.length)}>. Expected length was <#{mu_pp(expected)}>" }
|
214
|
+
assert_equal( expected, actual.length, msg )
|
215
|
+
else
|
216
|
+
flunk( "Bad reference value (first argument: #{expected.inspect}) to assert_length" )
|
161
217
|
end
|
162
218
|
end
|
219
|
+
|
220
|
+
# Tries the given methods on both objects, reports on differing results
|
221
|
+
# Doesn't take a custom message. Methods given must take zero arguments.
|
222
|
+
def assert_equality_of_methods( expected, actual, *methods )
|
223
|
+
failed = false
|
224
|
+
|
225
|
+
results_msg = {}
|
226
|
+
results_msg[:expected] = "The following methods were not equal: \nExpected: #{mu_pp(expected)}"
|
227
|
+
results_msg[:actual] = "\n--------------------\nActual: #{mu_pp(actual)}"
|
228
|
+
|
163
229
|
|
164
|
-
def assert_equality_of_methods(*args)
|
165
|
-
expected = args[0]
|
166
|
-
actual = args[1]
|
167
|
-
methods = args[2..-1].flatten
|
168
|
-
message = "The following methods were not equal: "
|
169
|
-
|
170
|
-
unequal = []
|
171
|
-
|
172
230
|
for method in methods
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
231
|
+
no_error_on_method = true
|
232
|
+
responses = {}
|
233
|
+
|
234
|
+
for obj, response_sym in [[expected, :expected], [actual, :actual]]
|
235
|
+
responses[response_sym] = begin
|
236
|
+
obj.send( method )
|
237
|
+
rescue StandardError => e
|
238
|
+
e
|
239
|
+
end
|
240
|
+
|
241
|
+
if responses[response_sym].is_a?( StandardError )
|
242
|
+
failed = true
|
243
|
+
no_error_on_method = false
|
244
|
+
results_msg[response_sym] << "\n\t#{method}(): ERROR: #{responses[response_sym].class} #{responses[response_sym].message}"
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
if responses[:expected] != responses[:actual] && no_error_on_method
|
249
|
+
failed = true
|
250
|
+
|
251
|
+
for response_sym in [:expected, :actual]
|
252
|
+
results_msg[response_sym] << "\n\t#{method}(): #{responses[response_sym].inspect}"
|
253
|
+
end
|
178
254
|
end
|
179
255
|
end
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
end
|
256
|
+
|
257
|
+
|
258
|
+
assert !failed, results_msg[:expected] + results_msg[:actual]
|
184
259
|
end
|
185
260
|
|
186
|
-
def assert_has_instance_method( object, instance_method,
|
187
|
-
|
188
|
-
|
189
|
-
end
|
261
|
+
def assert_has_instance_method( object, instance_method, msg = nil )
|
262
|
+
msg = message(msg){ "object #{mu_pp(object)} should respond to #{instance_method.inspect}" }
|
263
|
+
assert object.instance_methods.include?( instance_method ), msg
|
190
264
|
end
|
191
265
|
|
192
|
-
def assert_nothing_raised(
|
193
|
-
|
194
|
-
|
195
|
-
|
266
|
+
def assert_nothing_raised( msg = nil, &block )
|
267
|
+
begin
|
268
|
+
yield if block_given?
|
269
|
+
assert true
|
270
|
+
rescue Exception => e
|
271
|
+
msg = message(msg){ "block should not raise a #{mu_pp(e.class)} (message: #{e.message})"}
|
272
|
+
assert false, msg
|
196
273
|
end
|
197
274
|
end
|
198
275
|
end
|