On 21. mars. 2008, at 07.32, "Joe Van Dyk" <[EMAIL PROTECTED]> wrote:
> On Thu, Mar 20, 2008 at 2:05 AM, aslak hellesoy > <[EMAIL PROTECTED]> wrote: >> 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: > > rails_proj/stories/steps or just rails_proj/steps? Whichever you like. I prefer the first one. Aslak > > >> 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. > > 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. > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users