test_xml 0.1.5 → 0.1.6
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.md +4 -0
- data/lib/test_xml/assertions.rb +23 -0
- data/lib/test_xml/mini_test.rb +1 -2
- data/lib/test_xml/test_unit.rb +1 -28
- data/lib/test_xml/version.rb +1 -1
- metadata +1 -1
data/CHANGES.md
CHANGED
data/lib/test_xml/assertions.rb
CHANGED
@@ -41,4 +41,27 @@ module TestXml
|
|
41
41
|
:message_for_should_not => lambda { |a,b| "the xml:\n#{a}\nshould not exactly match xml structure:\n#{b} but it does" }
|
42
42
|
)
|
43
43
|
]
|
44
|
+
|
45
|
+
module Assertions
|
46
|
+
ASSERTIONS.each do |cfg|
|
47
|
+
define_method(cfg.assert_name) do |a, b|
|
48
|
+
correct_assert(MatcherMethods.send(cfg.name, a, b), cfg.message_for_should.call(a, b))
|
49
|
+
end
|
50
|
+
|
51
|
+
define_method(cfg.assert_not_name) do |a, b|
|
52
|
+
correct_assert(! MatcherMethods.send(cfg.name, a, b), cfg.message_for_should_not.call(a, b))
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
def correct_assert(boolean, message)
|
58
|
+
if RUBY_VERSION =~ /1.9.2/ or defined?(MiniTest)
|
59
|
+
assert(boolean, message)
|
60
|
+
else
|
61
|
+
assert_block(message) do
|
62
|
+
boolean
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
44
67
|
end
|
data/lib/test_xml/mini_test.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require "test_xml"
|
2
|
-
require "test_xml/test_unit"
|
3
2
|
|
4
3
|
# TODO: should we remove test_xml/spec?
|
5
4
|
MiniTest::Expectations.class_eval do
|
@@ -9,5 +8,5 @@ MiniTest::Expectations.class_eval do
|
|
9
8
|
end
|
10
9
|
|
11
10
|
class MiniTest::Test
|
12
|
-
include TestXml::
|
11
|
+
include TestXml::Assertions
|
13
12
|
end
|
data/lib/test_xml/test_unit.rb
CHANGED
@@ -1,33 +1,6 @@
|
|
1
1
|
require "test/unit"
|
2
2
|
require "test_xml"
|
3
3
|
|
4
|
-
module TestXml
|
5
|
-
module TestUnit
|
6
|
-
module Assertions
|
7
|
-
ASSERTIONS.each do |cfg|
|
8
|
-
define_method(cfg.assert_name) do |a, b|
|
9
|
-
correct_assert(MatcherMethods.send(cfg.name, a, b), cfg.message_for_should.call(a, b))
|
10
|
-
end
|
11
|
-
|
12
|
-
define_method(cfg.assert_not_name) do |a, b|
|
13
|
-
correct_assert(! MatcherMethods.send(cfg.name, a, b), cfg.message_for_should_not.call(a, b))
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
def correct_assert(boolean, message)
|
19
|
-
if RUBY_VERSION =~ /1.9.2/ or defined?(MiniTest)
|
20
|
-
assert(boolean, message)
|
21
|
-
else
|
22
|
-
assert_block(message) do
|
23
|
-
boolean
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
4
|
class Test::Unit::TestCase
|
32
|
-
include TestXml::
|
5
|
+
include TestXml::Assertions
|
33
6
|
end
|
data/lib/test_xml/version.rb
CHANGED