assert2 0.5.2 → 0.5.3
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/lib/assert2/rjs.rb +27 -8
- data/lib/assert2/xhtml.rb +8 -9
- metadata +2 -2
data/lib/assert2/rjs.rb
CHANGED
@@ -92,6 +92,13 @@ module Test; module Unit; module Assertions
|
|
92
92
|
@command = :call
|
93
93
|
pwn_call 'Element.remove', *args, &block
|
94
94
|
end
|
95
|
+
end # TODO get the call call out of the error message
|
96
|
+
|
97
|
+
class TOGGLE < AssertRjs
|
98
|
+
def pwn *args, &block
|
99
|
+
@command = :call
|
100
|
+
pwn_call 'Element.toggle', *args, &block
|
101
|
+
end
|
95
102
|
end
|
96
103
|
|
97
104
|
class CALL < AssertRjs
|
@@ -134,29 +141,41 @@ module Test; module Unit; module Assertions
|
|
134
141
|
end
|
135
142
|
end
|
136
143
|
|
137
|
-
def __interpret_rjs(command, *args, &block)
|
144
|
+
def __interpret_rjs(response, command, *args, &block)
|
138
145
|
klass = command.to_s.upcase
|
139
146
|
klass = eval("AssertRjs::#{klass}") rescue
|
140
147
|
flunk("#{command} not implemented!")
|
141
|
-
asserter = klass.new(
|
148
|
+
asserter = klass.new(response, command, self)
|
142
149
|
sample = asserter.pwn(*args, &block)
|
143
150
|
return sample, asserter
|
144
151
|
end
|
145
152
|
|
146
|
-
def assert_rjs_(
|
147
|
-
|
153
|
+
def assert_rjs_(*args, &block)
|
154
|
+
if args.first.class == Symbol
|
155
|
+
command, *args = *args
|
156
|
+
response = @response.body
|
157
|
+
else
|
158
|
+
response, command, *args = *args
|
159
|
+
end
|
160
|
+
|
161
|
+
sample, asserter = __interpret_rjs(response, command, *args, &block)
|
148
162
|
asserter.failure_message and flunk(asserter.failure_message)
|
149
163
|
return sample
|
150
164
|
end
|
151
165
|
|
152
|
-
def assert_no_rjs_(
|
153
|
-
|
166
|
+
def assert_no_rjs_(*args, &block)
|
167
|
+
if args.first.class == Symbol
|
168
|
+
command, *args = *args
|
169
|
+
response = @response.body
|
170
|
+
else
|
171
|
+
response, command, *args = *args # TODO test me!
|
172
|
+
end
|
173
|
+
|
174
|
+
sample, asserter = __interpret_rjs(response, command, *args, &block)
|
154
175
|
asserter.failure_message and return sample
|
155
176
|
flunk("should not find #{sample.inspect} in\n#{asserter.js}") # TODO complaint system
|
156
177
|
end
|
157
178
|
|
158
|
-
# TODO wrappers for RSpec
|
159
|
-
|
160
179
|
# command == :replace_html or # TODO put me inside the method_missing!
|
161
180
|
# flunk("assert_rjs's alpha version only respects :replace_html")
|
162
181
|
# TODO also crack out the args correctly and gripe if they wrong
|
data/lib/assert2/xhtml.rb
CHANGED
@@ -74,6 +74,7 @@ class BeHtmlWith
|
|
74
74
|
:message,
|
75
75
|
:reference,
|
76
76
|
:references,
|
77
|
+
:returnable,
|
77
78
|
:sample,
|
78
79
|
:scope
|
79
80
|
|
@@ -147,9 +148,12 @@ class BeHtmlWith
|
|
147
148
|
end
|
148
149
|
|
149
150
|
def match_xpath(path, &refer)
|
150
|
-
@doc.root.xpath_with_callback path, :refer do |element, index|
|
151
|
-
|
152
|
-
|
151
|
+
nodes = @doc.root.xpath_with_callback path, :refer do |element, index|
|
152
|
+
collect_samples(element, index.to_i)
|
153
|
+
end
|
154
|
+
|
155
|
+
@returnable ||= nodes.first # TODO be_with_html must get on board too
|
156
|
+
return nodes
|
153
157
|
end
|
154
158
|
|
155
159
|
# ERGO match text with internal spacies?
|
@@ -321,7 +325,7 @@ module Test; module Unit; module Assertions
|
|
321
325
|
matcher.matches?(xhtml, &block)
|
322
326
|
message = matcher.failure_message
|
323
327
|
flunk message if message.to_s != ''
|
324
|
-
|
328
|
+
return matcher.returnable
|
325
329
|
else
|
326
330
|
_assert_xml(xhtml)
|
327
331
|
return @xdoc
|
@@ -336,11 +340,6 @@ module Spec; module Matchers
|
|
336
340
|
end
|
337
341
|
end; end
|
338
342
|
|
339
|
-
class Nokogiri::XML::Node
|
340
|
-
def content= string
|
341
|
-
self.native_content = encode_special_chars(string.to_s)
|
342
|
-
end
|
343
|
-
end # ERGO retire these monkey patches as Nokogiri catches up
|
344
343
|
|
345
344
|
class Nokogiri::XML::Node
|
346
345
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: assert2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phlip
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-10 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|