StoryRunner docs/guidance

Hi all,

Are there any plans for better documentation for the new StoryRunner
feature? I tried to use it today (with Rails), and had a hard time
getting my head around whether I was doing it “right” and exactly what
things are appropriate to test at that level (this might be exacerbated
by the fact that I’ve never really used integration testing that much).
A full example of testing a Rails controller would be extremely useful
to me.

Thanks,

Jon


Jonathan L., Web D.
http://jonathanleighton.com/

Yeah, this is truly needed, you have a second from me.

Nathan S.
[email protected]
rspec 1.1
rspec_on_rails 1.1
rails 2.0.1

On 21 Dec 2007, at 19:59, Jonathan L. wrote:

to me.
No idea whether I’m doing it right either, but I’ve posted my
experiences, with some sample code, here:

http://www.kerrybuckley.com/2007/11/07/driving-selenium-from-the-rspec-story-runner-rbehave/

Obviously the bits that force it to use rspec trunk from an odd
directory aren’t needed any more.

Hope it helps,

Kerry

I just went through this myself yesterday, and was considering
posting an article on my blog, but figured it’d be too short lived,
once the doc page is up on the rspec site. So I’ll post here what
I’ve cobbled together from various other articles, emails, and
generous help on #rspec.

  1. DECIDE A DIRECTORY STRUCTURE AND FILL OUT helper.rb
    Directory structure:
    stories/
    stories/steps/
    stories/stories/
    stories/stories/foo
    stories/stories/foo/a_foo_story
    stories/stories/foo/a_foo_story.rb
    stories/stories/foo/another_foo_story
    stories/stories/foo/another_foo_story.rb
    stories/all.rb
    stories/helper.rb

File: stories/helper.rb:

ENV[“RAILS_ENV”] = “test”
require File.expand_path(File.dirname(FILE) + “/…/config/
environment”)
require ‘spec/rails/story_adapter’

Dir[‘stories/steps/**/*.rb’].each do |steps_file|
require steps_file
end

add extra include’s and helper methods here

include FixtureReplacement

  1. WRITE A SHORT TEXT STORY

File: stories/stories/admin/admin_accounts

Story: admin user manages accounts
As an admin user
I want site-wide access to accounts, projects, and users
So I can create and modify items

Scenario: admin user logs in
Given an admin user and account
And a bunch of accounts setup
When user logs in with email: [email protected] and password:
secret
Then browser should show the Admin page
And browser should show the Accounts table

  1. WRITE A rb SCRIPT FOR THE STORY

File: stories/stories/admin/admin_accounts.rb

require File.join(File.dirname(FILE), “…/…/helper”)

with_steps_for :misc do
run File.expand_path(FILE).gsub(".rb",""), :type => RailsStory
end

For other stories, just copy this file, and add/change the steps
groups as required. The rest of the file is unchanged (it gets the
text story filename from its own name.)

3.A And Run It:

$ ruby stories/stories/admin/admin_accounts.rb

should show 1 scenarios: 0 succeeded, 0 failed, 1 pending

  1. CODE THE STEPS
    To start, I put all my steps into a “miscellaneous” steps file until
    patterns emerge when I’ll separate them out into different steps files

File: stores/steps/misc_steps.rb

steps_for(:misc) do
Given “an admin user and account” do
@user = create_user( :email => “[email protected]”, :password =>
‘secret’, :site_admin => true)
end

Given “a bunch of accounts setup” do
4.times do
create_account
end
end

When “user logs in with email: $email and password: $password” do |
email, password|
post_via_redirect “/sessions”, :email => email, :password =>
password, :account => account
response.should be_success
session[:user].should == @user.id # should_be_logged_in(@user)
end

Then “browser should show the $h1_contents page” do |h1_contents|
response.should have_tag(“h1”, h1_contents)
end

Then “browser should show the $table_name table” do |table_name|
response.should have_tag(“div h2”, table_name)
end
end

4.A And Run It

$ ruby stories/stories/admin/admin_accounts.rb
or
$ ruby stories/all.rb

–linoj

I never really thought of placing subdirectories in the stories
directory.
I guess that would be useful for separating your administrative stories
for
the back end of your app.

I named my stories in the following convention:

#role#_#action#_story.rb

eg:
user_creates_project_story.rb
user_edits_project_story.rb
user_deletes_project_story.rb
user_views_project_story.rb

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs