expectations 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- data/lib/expectations/xml_string.rb +9 -2
- data/rakefile.rb +1 -1
- data/test/expectations/xml_string_test.rb +16 -0
- metadata +1 -1
data/README
CHANGED
@@ -18,7 +18,7 @@ expectations is designed to encourage unit testing best practices such as
|
|
18
18
|
|
19
19
|
Mocking is done utilizing Mocha[http://mocha.rubyforge.org]
|
20
20
|
|
21
|
-
by Jay
|
21
|
+
by {Jay Fields}[http://blog.jayfields.com]
|
22
22
|
|
23
23
|
== Download and Installation
|
24
24
|
|
@@ -1,10 +1,17 @@
|
|
1
1
|
class Expectations::XmlString < String
|
2
2
|
|
3
3
|
def expectations_equal_to(other)
|
4
|
-
|
4
|
+
not Regexp.new(normalize(self)).match(normalize(other)).nil?
|
5
5
|
end
|
6
6
|
|
7
7
|
def inspect
|
8
|
-
"[as xml] #{self
|
8
|
+
"[as xml] #{normalize(self)}"
|
9
9
|
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
def normalize(xml_string)
|
14
|
+
xml_string.strip.gsub(/>\s*</, "><")
|
15
|
+
end
|
16
|
+
|
10
17
|
end
|
data/rakefile.rb
CHANGED
@@ -46,7 +46,7 @@ specification = Gem::Specification.new do |s|
|
|
46
46
|
expect NoMethodError do
|
47
47
|
Object.invalid_method_call
|
48
48
|
end."
|
49
|
-
s.version = "0.1.
|
49
|
+
s.version = "0.1.6"
|
50
50
|
s.author = 'Jay Fields'
|
51
51
|
s.description = "A lightweight unit testing framework. Tests (expectations) will be written as follows
|
52
52
|
expect 2 do
|
@@ -5,6 +5,14 @@ Expectations do
|
|
5
5
|
Expectations::XmlString.new("<foo>bar</foo>").expectations_equal_to "<foo>bar</foo>"
|
6
6
|
end
|
7
7
|
|
8
|
+
expect false do
|
9
|
+
Expectations::XmlString.new("<foo>not bar</foo>").expectations_equal_to "<foo>bar</foo>"
|
10
|
+
end
|
11
|
+
|
12
|
+
expect false do
|
13
|
+
Expectations::XmlString.new("<not-foo>bar</not-foo>").expectations_equal_to "<foo>bar</foo>"
|
14
|
+
end
|
15
|
+
|
8
16
|
expect true do
|
9
17
|
Expectations::XmlString.new("<foo>bar</foo>").expectations_equal_to " <foo>bar</foo> "
|
10
18
|
end
|
@@ -41,4 +49,12 @@ Expectations do
|
|
41
49
|
Expectations::XmlString.new("<a>\n<foo>\t \n bar</foo>\n \t </a>").expectations_equal_to "<a><foo>\t \n bar</foo></a>"
|
42
50
|
end
|
43
51
|
|
52
|
+
expect true do
|
53
|
+
Expectations::XmlString.new("<fragment>content</fragment>").expectations_equal_to "<container><fragment>content</fragment></container>"
|
54
|
+
end
|
55
|
+
|
56
|
+
expect "[as xml] <fragment>content</fragment>" do
|
57
|
+
Expectations::XmlString.new(" \t<fragment>content</fragment>\n ").inspect
|
58
|
+
end
|
59
|
+
|
44
60
|
end
|