Forum: RSpec Sharing the little dialects we write in Cucumber

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Matt W. (Guest)
on 2008-11-08 12:03
(Received via mailing list)
The common_webrat.rb steps file that comes with cucumber when you add
it to rails really inspired our team.

We've extended it a fair bit to do various other things to check the
content of a page such as [1] which enable us to write steps like this:

  Then I should see the text "dave" within the "friends" list

We also have a bunch of generic steps that work with the factory_girl
plugin to allow us easily create / manipulate different domain objects
like this:

  Given there is a User
or
  Given there are 3 Concerts

Also, I've started writing some specs for a command-line tool, and
will have a few steps that work with the command-line

  When I issue the command "ls"

I feel like I want to share this stuff and collaborate on it in a
broader group outside our team but I'm not sure what would be the
appropriate route. Obviously this stuff is pretty easy to re-use - you
just have to require a ruby file that defines the steps so it's not
like cucumber needs a plug-in manager exactly...

What do people think? Is this stuff so trivially easy to other people
that they prefer just to write it from scratch? Or are you also
writing step matchers that you think other people could be using? How
do you think we could best share them and collaborate on them?

cheers,
Matt

[1]http://gist.github.com/23044
Pau C. (Guest)
on 2008-11-08 12:34
Matt W. wrote:
> What do people think? Is this stuff so trivially easy to other people
> that they prefer just to write it from scratch?

I think that sharing these will be a really good way to help people
learning Cucumber write better features and steps.

Writing cucumber features that pass is easy. Writing ones that are easy
to maintain, increase confidence, and document functionality is REALLY
hard (at least to learn).

Being able to start with a lot of well written steps would get people on
the right track.

> How do you think we could best share them and collaborate on them?
I think some could go on the Wiki.
aslak hellesoy (Guest)
on 2008-11-08 13:34
(Received via mailing list)
On Sat, Nov 8, 2008 at 11:01 AM, Matt W. <removed_email_address@domain.invalid> 
wrote:
>
> group outside our team but I'm not sure what would be the appropriate route.
> Obviously this stuff is pretty easy to re-use - you just have to require a
> ruby file that defines the steps so it's not like cucumber needs a plug-in
> manager exactly...
>
> What do people think? Is this stuff so trivially easy to other people that
> they prefer just to write it from scratch? Or are you also writing step
> matchers that you think other people could be using? How do you think we
> could best share them and collaborate on them?
>

I think some basic steps for output validation is good. I like the
essence in yours. Please add it in your fork.
Matt W. (Guest)
on 2008-11-08 16:20
(Received via mailing list)
On 8 Nov 2008, at 11:22, aslak hellesoy wrote:
>> I feel like I want to share this stuff and collaborate on it in a
>> people that
>> they prefer just to write it from scratch? Or are you also writing
>> step
>> matchers that you think other people could be using? How do you
>> think we
>> could best share them and collaborate on them?
>>
>
> I think some basic steps for output validation is good. I like the
> essence in yours. Please add it in your fork.

Glad you like the idea :)

Okay, tentatively, I've factored over the obvious steps I can see in
our project that could easily be reused:

http://github.com/songkick/cucumber/commit/b80da2b...

This would mean that the sample 'common_webrat.rb' step that's created
by the rails generator could just consist of the following line:

     require 'cucumber/steps_library/webrat'

In fact, this could just go into env.rb - that's what I've done in our
project now the code is factored away in cucumber.

Now this is just a spike, and I have my concerns / thoughts:
   * If other people are going to be depending on these steps, they
really need automated tests of some sort that ship alongside them.
   * I've introduced three new methods in the global namespace - yuck!
     * How should these best be factored away somewhere non-polluting?
     * Should within_list() go into webrat maybe?
  * Is 'cucumber/steps_library' the right name / place to put these?
Could be 'step_matchers_library' instead maybe?
  * If we're going to start squirrelling step matchers away in a
library / libraries, do we need a way to ask the StepMother to list
them (kinda like rake routes)?

Okay that's it for now. All feedback extremely welcome :)

cheers,
Matt
This topic is locked and can not be replied to.