Sharing story steps

Hi,

How can I have a common set of steps that all my stories share?

i.e. My stories often start out looking like this:

Given a user Joe
Given a user Jordan

then:

Given(“a user $username”) do |username|
@users ||= {}
@user_sessions ||= {}
@users[username] = create_user(:username => username)
@user_sessions[username] = login_as(@users[username])
end

I want to share that Given with all my stories. Or is there a better
way to do it?

Joe

On Thu, Mar 20, 2008 at 5:44 AM, Joe Van D. [email protected] wrote:

Hi,

How can I have a common set of steps that all my stories share?

i.e. My stories often start out looking like this:

Given a user Joe
Given a user Jordan

then:

put this in steps/users.rb:

steps_for(:user) do

Given(“a user $username”) do |username|
@users ||= {}
@user_sessions ||= {}
@users[username] = create_user(:username => username)
@user_sessions[username] = login_as(@users[username])
end

end

Now, in your file running stories:

with_steps_for(:user, :project, :comment) do

end

I want to share that Given with all my stories. Or is there a better
way to do it?

At one of our current projects in BEKK we have come up with a
convention for naming and grouping steps. It simply follows the same
convention as the controllers for file names, and in each file we put
all steps that are relevant to a given controller.

In the run file we simply run stories with_steps_for all of them.

Try it out, I think you’ll like it.

Aslak

On Thu, Mar 20, 2008 at 2:05 AM, aslak hellesoy
[email protected] wrote:

then:

put this in steps/users.rb:

rails_proj/stories/steps or just rails_proj/steps?

At one of our current projects in BEKK we have come up with a
convention for naming and grouping steps. It simply follows the same
convention as the controllers for file names, and in each file we put
all steps that are relevant to a given controller.

Makes sense.

In the run file we simply run stories with_steps_for all of them.

Try it out, I think you’ll like it.

Thanks, I will.

On 21. mars. 2008, at 07.32, “Joe Van D.” [email protected] wrote:

Given a user Joe
Given a user Jordan

then:

put this in steps/users.rb:

rails_proj/stories/steps or just rails_proj/steps?

Whichever you like. I prefer the first one.

Aslak

On Fri, Mar 21, 2008 at 10:35 AM, Aslak
Hellesøy[email protected] wrote:

How can I have a common set of steps that all my stories share?
rails_proj/stories/steps or just rails_proj/steps?

Whichever you like. I prefer the first one.

I prefer the first one as well,

On Mar 21, 2008, at 2:35 pm, Aslak Hellesøy wrote:

rails_proj/stories/steps or just rails_proj/steps?

Whichever you like. I prefer the first one.

I ended up creating RAILS_ROOT/stories/stories and RAILS_ROOT/stories/
steps

I don’t like the duplication of “stories” but I prefer it to
(apparently) having a group of stories called “steps”. I also have a
folder called RAILS_ROOT/stories/story_support where I’ve dumped
selenium extensions etc. But arguably I should pull that out into
vendor/gems or something.

Ashley