On Sat, Mar 28, 2009 at 1:49 PM, Brandon Olivares <programmer2...@gmail.com> wrote: > Hi, > > So, I'm confused. I've been trying to use Cucumber and RSpec, but step > definitions and RSpec examples just seem to be overlapping. What should go > in either one of these? > > For instance, let's say I'm testing if a form exists on a page. What goes in > Cucumber and what goes in RSpec? > > What I did for now is put Webrat methods in the step definitions, like > fill_in, select, etc, without submitting since I'm not testing processing > yet; and then put selector matchers in the RSpec examples. > > But I have no idea if that's right. How do you separate these and keep them > from duplicating one another? > > Thanks, > Brandon > > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
So far I've not found a situation where I want to just test a form's existence at the acceptance level - I always just submit the form. Then I might write a couple RSpec examples to verify the presence/absence of that form in certain situations. Occasionally there is duplication between your acceptance and unit tests - I think that's okay. Acceptance tests verify the behavior at the application level, and unit tests generally do a better job of defect localization. I try to minimize that duplication though, and frequently I will sacrifice the defect localization and only test that behavior through Cucumber. Then I go back and write the unit test the first time I experience a problem and it takes me longer to track down than it should have :) Pat _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users