Shalon Wood wrote:
>> I know that rspec when used with rails allows you to write something
>> like -
>>
>> response.should have_tag('div#some_id', 'some_text')
>
> response.should have_xpath("//div[id()='some_id'][text()*='some_text']")
> should do it, off the top of my head.
I have been getting around to writing this up, but I suspect you can also...
gem install assert2
require 'assert2/xpath'
assert_xhtml @response.body # this line will go away soon
xpath :div, :some_id do |div|
div.text =~ /some_text/ and
assert :a, :href => 'http://example.com', ?. => 'some_more_text'
end
That system exposes XPath as a Ruby DSL, so you don't have to perform elaborate
string surgery (or worse) when your string payloads get more complicated. If it
fails, the failures are disjoint, where one big XPath only tells you, "ain't
found; deal!" You also get a complete, detailed, formatted diagnostic.
But tell me if you get stuck, because I have not yet game-tested it with Merb...
--
Phlip
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---