On 27 September 2013 08:37, Atish kumar <li...@ruby-forum.com> wrote:
> how to write “Destroy kid” in cucumber > > Scenario: User can delete kids > Given I am on the kids page > When I Destroy kid > Then I should see "Kid deleted successfully" > Then one kid should not exist > > > > <h1>Listing kids</h1> > > <tr> > <th>Kid name</th> > <th colspan=3>Action</th> > </tr> > <% @kids.each do |kid| %> > <tr> > <td><%= kid.kid_name %></td> > <td><%= link_to 'Show', kid %></td> > <td><%= link_to 'Edit', edit_kid_path(kid) %></td> > <td><%= link_to 'Destroy', kid, method: :delete, > data: { confirm: 'Are you sure?' } %></td> > </tr> > > <% end %> > > <%= link_to 'New Kid', new_kid_path %> > > what to write for this step: > > When /^I Destroy kid$/ do > #what to write...... > end > > You need to change the markup and have a unique id for the tr containing each kid. You can apply this for all collections. So forgetting the html, and in haml .kids = render partial: kid, collection: @collection, as: :kid // singular partial .kid{id="kid_#{kid.id}"} =link_to 'Destroy' ... Your test is telling you your markup sux (thats why its so difficult to test). So instead of making the test do something really difficult, listen to your test and improve your code. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -- ------------------------ Andrew Premdas blog.andrew.premdas.org
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users