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?
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.
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.
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:
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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.