aslak hellesoy
2008-Oct-26 23:43 UTC
[rspec-users] Testing item links in Webrat (was: Cucumber)
On Sun, Oct 26, 2008 at 11:30 PM, Mark Thomson <mark.thomson at ieee.org> wrote:> I have an index template that contains a tabulated list of database items, > each of which has an associated "display" link that enables the item to be > displayed via a "show" action. In Cucumber I know how to test that the show > template is rendered when one of those links is clicked using webrat''s > "click_link" method and response.should render_template. >This is a Webrat question - not a Cucumber question.> What I''m not sure about is whether it''s possible to specify that a > particular link gets clicked, since there are multiple links on the page > with the same text. I''d like to be able to test that the particular databaseUse the #clicks_link_within method in Webrat. Aslak> record that gets used in the show template corresponds to the one whose > display link was clicked. > > Any thoughts on this? Is a story-level test the right place to be checking > this, or should it be handled in an object level test? > > Mark. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Mark Thomson
2008-Oct-27 00:01 UTC
[rspec-users] Testing item links in Webrat (was: Cucumber)
aslak hellesoy wrote:> On Sun, Oct 26, 2008 at 11:30 PM, Mark Thomson <mark.thomson at ieee.org> wrote: > >> I have an index template that contains a tabulated list of database items, >> each of which has an associated "display" link that enables the item to be >> displayed via a "show" action. In Cucumber I know how to test that the show >> template is rendered when one of those links is clicked using webrat''s >> "click_link" method and response.should render_template. >> >> > > This is a Webrat question - not a Cucumber question. >Only if you know the answer :-)> >> What I''m not sure about is whether it''s possible to specify that a >> particular link gets clicked, since there are multiple links on the page >> with the same text. I''d like to be able to test that the particular database >> > > Use the #clicks_link_within method in Webrat. > > Aslak >Thanks Aslak. You''ve made me realize I have been looking at an old version of the documentation, here: http://www.brynary.com/uploads/webrat/rdoc/index.html. So I didn''t realize there was a click_links_within method. Google has just led me here: http://webrat.rubyforge.org/. Mark. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081026/532620ea/attachment.html>
Josh Knowles
2008-Oct-27 03:08 UTC
[rspec-users] Testing item links in Webrat (was: Cucumber)
On 10/26/08, Mark Thomson <mark.thomson at ieee.org> wrote:> Google has just led me here: http://webrat.rubyforge.org/.Please make sure you view http://github.com/brynary/webrat/tree/master for the latest code as things change much faster they they get pushed up to RubyForge. -- Josh Knowles phone: 509-979-1593 email: joshknowles at gmail.com web: http://joshknowles.com
Mark Thomson
2008-Oct-27 03:18 UTC
[rspec-users] Testing item links in Webrat (was: Cucumber)
Josh Knowles wrote:> On 10/26/08, Mark Thomson <mark.thomson at ieee.org> wrote: > > >> Google has just led me here: http://webrat.rubyforge.org/. >> > > Please make sure you view http://github.com/brynary/webrat/tree/master > for the latest code as things change much faster they they get pushed > up to RubyForge. >Thanks, although note that that also leads back to the old documentation.
Matt Wynne
2008-Oct-27 08:09 UTC
[rspec-users] Testing item links in Webrat (was: Cucumber)
On 27 Oct 2008, at 00:01, Mark Thomson wrote:> aslak hellesoy wrote: >> >>> What I''m not sure about is whether it''s possible to specify that a >>> particular link gets clicked, since there are multiple links on >>> the page >>> with the same text. I''d like to be able to test that the >>> particular database >> Use the #clicks_link_within method in Webrat. > Thanks Aslak. You''ve made me realize I have been looking at an old > version of the documentation, here: http://www.brynary.com/uploads/webrat/rdoc/index.html > . So I didn''t realize there was a click_links_within method. Google > has just led me here: http://webrat.rubyforge.org/.The webrat code is very simple and readable IMO, even for a ruby newbie like me. When I''m wondering how to do something, I usually just open the source. I think there''s also a #within call which takes a block, so you might be able to do something like. within :div_for_object_123 do clicks_link ''Follow Me'' end This is based on a conversation I heard over the other side of the desk, so take it with a pinch of salt ;) cheers, Matt