[rspec-users] Sharing the little dialects we write in Cucumber
matt at mattwynne.net
Sat Nov 8 09:16:25 EST 2008
On 8 Nov 2008, at 11:22, aslak hellesoy wrote:
> On Sat, Nov 8, 2008 at 11:01 AM, Matt Wynne <matt at mattwynne.net>
>> 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  which enable us to write steps like this:
>> I feel like I want to share this stuff and collaborate on it in a
>> 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
>> 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
>> 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:
This would mean that the sample 'common_webrat.rb' step that's created
by the rails generator could just consist of the following line:
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 :)
More information about the rspec-users