[rspec-users] Specing Ajaxy Views
matt at mattwynne.net
Sun Jan 2 11:21:08 EST 2011
On 30 Dec 2010, at 03:43, Shea Levy wrote:
> Hi all,
> I am working on a feature to allow administrators of an online store to rearrange the order in which their product categories show up on the site. I want to use a simple implementation of sortable_lists (madrobby.github.com/scriptaculous/sortable-lists-demo/) to allow the administrators to just drag and drop the categories into the desired order. I have already written a cucumber feature that I hope expresses the desired function (does anyone know if Capybara+Selenium's drag_to method will work with sortable_lists?), and have gotten to red on the Cucumber level, but I'm at a loss as to how to continue. The Cucumber scenario goes to the page, drags each category to the desired spot, then reloads the page to check that the categories are in the right order. The When (dragging each category) passes (though the dragging doesn't actually do anything, since the sortable_list is not set up yet), but the Then (checking the categories) fails because nothing was actually changed. I think my next step should be a view spec, but I'm not sure exactly how to proceed. I think what I want to check on the view level is a) that clicking and dragging updates the document and b) that the proper AJAX request is sent to the controller, but I don't know how to do either. Once I got those working, the next step (specing the controller which responds to the request) seems easier, but I don't know how to get past this part.
In general, when I'm in a situation where I'm not sure how to test drive something, I will create a branch in git and implement it as a spike. I might well use Cucumber to help me drive the spike. Then I'll reflect on what I would want tests for: what am I worried could break, and how would I want to be notified? Sometimes I decide that there's so little code that I don't need any specs, and I can just rely on the Cucumber test. In that case I'll merge the branch into master and move on.
> rspec-users mailing list
> rspec-users at rubyforge.org
matt at mattwynne.net
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rspec-users