[Ruby] matching spaces as \s+ in assert_select
James Moore
banshee at banshee.com
Thu Dec 6 14:46:56 PST 2007
On 12/6/07, James Moore <banshee at banshee.com> wrote:
> def assert_select_one_whitespace &block
> html = @response.body.gsub(/\s+/, ' ')
> doc = HTML::Document.new(html, false, true)
> assert_select doc.root, ':root', &block
> end
A little too much cut-and-paste there. The code above was copied for
what I do for XML:
def with_xml xml, &block
doc = HTML::Document.new(xml, false, true)
assert_select doc.root, ':root', &block
end
Called with:
with_xml(some_xml_text) do
assert_tag ...
end
You'd probaby want to drop the last two parameters to
HTML::Document.new for the spaceless-html code.
--
James Moore | james at restphone.com
Interested in hooking up phone calls to your Ruby on Rails site?
Send me mail about the RESTPhone beta.
blog.restphone.com
More information about the Ruby
mailing list