On 6 May 2009, at 19:28, John Goodsen wrote:

Another thing I'm looking into is trying to hook into the visitor/ formatting stuff and just spit out the extra data fixture data when the test runs... thoughts anyone?

On Wed, May 6, 2009 at 2:13 PM, John Goodsen <jgood...@radsoft.com> wrote: I have the following step that I want to re-use in several scenarios. It looks like this:

 When I submit the form
   |form_field_id               |value|
   |billingAddress.email        |mickey_mo...@test.com|
   |billingAddress.firstName    |Mickey|
   |billingAddress.lastName     |Mouse|
   |billingAddress.street1      |249 Cross Road|
   |billingAddress.city         |Sanford|
   |billingAddress.subCountry   |ME|
   |billingAddress.zipPostalCode|04073|
   |billingAddress.country      |US|

This step fills out a form using Selenium behind the scenes. It's been copied into several scenarios and I want to DRY it up. I DRY'd this up by moving this table data into a fixture file (mickey_mouse.yml), but then the test becomes less descriptive - the original scenario step above turned into a one-liner:

 When I submit the form for "mickey_mouse"

I think ideally, I would like some kind of "include_step" feature in cucumber - where we can write partial snippets and include them wherever I want. When cucumber runs, it can replace the included step. So I could keep my tests DRY with something like:

    When I submit the form
      Include 'submit_form_for_mickey_mouse'

but when I run the test, cucumber would spit out the partial contents in place of the Include to make the test more descriptive.

Is there anything in cucumber that would help me out right now? What I'm currently looking into is hooking into the formatting and overriding some rendering - but it feels like a bad hack.

Why not write a wrapper step, something like

Given /I submit the billing address form with valid data/ do
  submit_form {
    :email => 'mickey_mo...@test.com',
    :firstName => 'Mickey'} # etc
end

And call that from your feature? Do you really need to see all the fields in the formatted output? Are they relevant to the particular scenario you're building, or just noise?

Matt Wynne
http://blog.mattwynne.net
http://www.songkick.com

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

Reply via email to