I never really thought of placing subdirectories in the stories directory.<br>I guess that would be useful for separating your administrative stories for the back end of your app.<br><br>I named my stories in the following convention:
<br><br>#role#_#action#_story.rb<br><br>eg:<br>user_creates_project_story.rb<br>user_edits_project_story.rb<br>user_deletes_project_story.rb<br>user_views_project_story.rb<br><br><br><div class="gmail_quote">On Dec 21, 2007 6:40 PM, Jonathan Linowes <
<a href="mailto:jonathan@parkerhill.com">jonathan@parkerhill.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I just went through this myself yesterday, and was considering
<br>posting an article on my blog, but figured it'd be too short lived,<br>once the doc page is up on the rspec site. So I'll post here what<br>I've cobbled together from various other articles, emails, and<br>
generous help on #rspec.<br><br>1. DECIDE A DIRECTORY STRUCTURE AND FILL OUT helper.rb<br>Directory structure:<br>stories/<br>stories/steps/<br>stories/stories/<br>stories/stories/foo<br>stories/stories/foo/a_foo_story<br>
stories/stories/foo/a_foo_story.rb<br>stories/stories/foo/another_foo_story<br>stories/stories/foo/another_foo_story.rb<br>stories/all.rb<br>stories/helper.rb<br><br>File: stories/helper.rb:<br><br>ENV["RAILS_ENV"] = "test"
<br>require File.expand_path(File.dirname(__FILE__) + "/../config/<br>environment")<br>require 'spec/rails/story_adapter'<br><br>Dir['stories/steps/**/*.rb'].each do |steps_file|<br> require steps_file
<br>end<br><br># add extra include's and helper methods here<br>include FixtureReplacement<br><br><br>2. WRITE A SHORT TEXT STORY<br><br>File: stories/stories/admin/admin_accounts<br><br>Story: admin user manages accounts
<br> As an admin user<br> I want site-wide access to accounts, projects, and users<br> So I can create and modify items<br><br> Scenario: admin user logs in<br> Given an admin user and account<br> And a bunch of accounts setup
<br> When user logs in with email: <a href="mailto:admin@example.com">admin@example.com</a> and password:<br>secret<br> Then browser should show the Admin page<br> And browser should show the Accounts table<br>
<br><br>3. WRITE A rb SCRIPT FOR THE STORY<br><br>File: stories/stories/admin/admin_accounts.rb<br><br>require File.join(File.dirname(__FILE__), "../../helper")<br><br>with_steps_for :misc do<br> run File.expand_path
(__FILE__).gsub(".rb",""), :type => RailsStory<br>end<br><br>For other stories, just copy this file, and add/change the steps<br>groups as required. The rest of the file is unchanged (it gets the<br>
text story filename from its own name.)<br><br><br>3.A And Run It:<br><br> $ ruby stories/stories/admin/admin_accounts.rb<br><br>should show 1 scenarios: 0 succeeded, 0 failed, 1 pending<br><br><br>4. CODE THE STEPS
<br>To start, I put all my steps into a "miscellaneous" steps file until<br>patterns emerge when I'll separate them out into different steps files<br><br>File: stores/steps/misc_steps.rb<br><br>steps_for(:misc) do
<br> Given "an admin user and account" do<br> @user = create_user( :email => "<a href="mailto:admin@example.com">admin@example.com</a>", :password =><br>'secret', :site_admin => true)
<br> end<br><br> Given "a bunch of accounts setup" do<br> 4.times do<br> create_account<br> end<br> end<br><br> When "user logs in with email: $email and password: $password" do |
<br>email, password|<br> post_via_redirect "/sessions", :email => email, :password =><br>password, :account => account<br> response.should be_success<br> session[:user].should == @<a href="http://user.id" target="_blank">
user.id</a> # should_be_logged_in(@user)<br> end<br><br> Then "browser should show the $h1_contents page" do |h1_contents|<br> response.should have_tag("h1", h1_contents)<br> end<br><br> Then "browser should show the $table_name table" do |table_name|
<br> response.should have_tag("div h2", table_name)<br> end<br>end<br><br>4.A And Run It<br><br> $ ruby stories/stories/admin/admin_accounts.rb<br>or<br> $ ruby stories/all.rb<br><br><br><br>
<br>--linoj<br><div class="Ih2E3d"><br><br><br><br><br>On Dec 21, 2007, at 2:59 PM, Jonathan Leighton wrote:<br><br></div><div><div></div><div class="Wj3C7c">> Hi all,<br>><br>> Are there any plans for better documentation for the new StoryRunner
<br>> feature? I tried to use it today (with Rails), and had a hard time<br>> getting my head around whether I was doing it "right" and exactly what<br>> things are appropriate to test at that level (this might be
<br>> exacerbated<br>> by the fact that I've never really used integration testing that<br>> much).<br>> A full example of testing a Rails controller would be extremely useful<br>> to me.<br>><br>> Thanks,
<br>><br>> Jon<br>><br>> --<br>> Jonathan Leighton, Web Developer<br>> <a href="http://jonathanleighton.com/" target="_blank">http://jonathanleighton.com/</a><br>><br>> _______________________________________________
<br>> rspec-users mailing list<br>> <a href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a><br>> <a href="http://rubyforge.org/mailman/listinfo/rspec-users" target="_blank">http://rubyforge.org/mailman/listinfo/rspec-users
</a><br><br>_______________________________________________<br>rspec-users mailing list<br><a href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a><br><a href="http://rubyforge.org/mailman/listinfo/rspec-users" target="_blank">
http://rubyforge.org/mailman/listinfo/rspec-users</a><br></div></div></blockquote></div><br>