Fun assertion example to kick off the Gizmo Group!

0 views
Skip to first unread message

impurist

unread,
Apr 11, 2010, 6:53:57 PM4/11/10
to gizmo - page-model testing
How about a fun assertion example :)

To ensure the following html exists on a page

<div id="party">
Gizmo Party
</div>

on_page_with :gizmo_party do |page|
page.should have_party
page.party_text.should == "Gizmo Party"
end

The page mixin would be the following

module PageWithGizmoParty
def has_party?
@document.xpath(party_selector) > 0
end

def party_text
@document.xpath(party_selector).inner_text
end

private
def party_selector
"//div[@id=party]"
end
end

This the way I have being using page models thus far.

Look at OpenSruct closure style on github for a more elegent examples.

:)
Steven

Reply all
Reply to author
Forward
0 new messages