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.
>
> 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?
>
>
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.
> Cheers,
> Shea
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
cheers,
Matt
matt at mattwynne.net
07974 430184
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/rspec-users/attachments/20110102/edc7e71f/attachment.html>