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. 

Also,
it occurs to me that, since I didn't write the sortable_list code myself,
maybe I should view it as an external API and my view spec should just
check that the view is set up properly to interact with the API. Does that
make more sense? How would I do that? In general, if I want to add
Javascript functionality to a view, should I treat the scripting itself as
a separate component to be "speced" with something like JsUnit as part of
the inner circle of the BDD cycle, along with specing views, controllers,
and models, or is there ever a time when Javascript specs should be
considered the responsibility of the view spec? 

Cheers,
 Shea
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to