Hi all, Suppose I have a table that lists all of my products, that includes a a somewhere in the first , and each product has its data held within a . After updating a product''s description, I want to write something like: within "tr#category#{category.id}" do under_header "Description" do |scope| scope.contains "New Description" end end in a Cucumber/webrat feature definition or response.should have_tag("tr#category1") do under_header "Description" do text => "Howdy end end in an RSpec spec. Is there anything like this available, any way to search within a specific table column by specifying the header? Cheers, Shea -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20101228/cd64a161/attachment.html>
On Dec 29, 2010, at 1:14 AM, Shea Levy wrote:> Hi all, > > Suppose I have a table that lists all of my products, that includes a a <th>Description</th> somewhere in the first <tr>, and each product has its data held within a <tr id="product<%= product.id %>">. After updating a product''s description, I want to write something like: > > within "tr#category#{category.id}" do > under_header "Description" do |scope| > scope.contains "New Description" > end > end > > in a Cucumber/webrat feature definition or > >not exactly what you''re asking but I do this: Then I should see "New description" on the row containing "Widget Xyz" Then /^(?:|I )should see "([^"]*)" on the row containing "([^"]*)"(?: within "([^"]*)")?$/ do |text1, text, scope| selector = ".//td[contains(.,''#{text}'')]//.." with_scope(scope) do within(:xpath, selector) do Then %{I should see "#{text1}"} end end end> response.should have_tag("tr#category1") do > under_header "Description" do > text => "Howdy > end > end > > in an RSpec spec. Is there anything like this available, any way to search within a specific table column by specifying the header? > > Cheers, > Shea > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20101229/f9ad12e0/attachment.html>
On 29 Dec 2010, at 06:14, Shea Levy wrote:> Hi all, > > Suppose I have a table that lists all of my products, that includes a a <th>Description</th> somewhere in the first <tr>, and each product has its data held within a <tr id="product<%= product.id %>">. After updating a product''s description, I want to write something like: > > within "tr#category#{category.id}" do > under_header "Description" do |scope| > scope.contains "New Description" > end > end > > in a Cucumber/webrat feature definition or > > response.should have_tag("tr#category1") do > under_header "Description" do > text => "Howdy > end > end > > in an RSpec spec. Is there anything like this available, any way to search within a specific table column by specifying the header? > > Cheers, > Shea > >It''s worth looking at the tableish method that cucumber-rails provides. You can use it to turn a HTML table element into an array. You can even diff it against a Cucumber::Ast::Table object. cheers, Matt matt at mattwynne.net 07974 430184 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20101229/d65f0538/attachment-0001.html>
On 29 Dec 2010, at 10:21, Matt Wynne wrote:> > On 29 Dec 2010, at 06:14, Shea Levy wrote: > >> Hi all, >> >> Suppose I have a table that lists all of my products, that includes a a <th>Description</th> somewhere in the first <tr>, and each product has its data held within a <tr id="product<%= product.id %>">. After updating a product''s description, I want to write something like: >> >> within "tr#category#{category.id}" do >> under_header "Description" do |scope| >> scope.contains "New Description" >> end >> end >> >> in a Cucumber/webrat feature definition or >> >> response.should have_tag("tr#category1") do >> under_header "Description" do >> text => "Howdy >> end >> end >> >> in an RSpec spec. Is there anything like this available, any way to search within a specific table column by specifying the header? >> >> Cheers, >> Shea >> >> > > It''s worth looking at the tableish method that cucumber-rails provides. You can use it to turn a HTML table element into an array. You can even diff it against a Cucumber::Ast::Table object.Oops, just realised you''re posting to the RSpec, not the Cucumber list. My mistake. cheers, Matt matt at mattwynne.net 07974 430184 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20101229/1a97356a/attachment.html>