On Thu, Mar 20, 2008 at 5:44 AM, Joe Van Dyk <[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
> Joe
> _______________________________________________
> rspec-users mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users