[rspec-users] Confused - which is the correct Story API

Jim Morris wolfmanjm at gmail.com
Tue Jun 17 18:17:13 EDT 2008


Hi,

I am confused (a normal state for me) about the State-Of-The-Art Story
API to use.

examples/calculator.rb has one syntax, the Blogs have another Syntax,
so do the various tutorials.

I realize that Stories are ongoing work, but it would be nice if there
were something I could refer to to make sure that I am not using a
syntax that will soon be deprecated, and that I am doing "what is
right".

So for Plain text stories I believe the current SOTA syntax is...

-- text file mystory.story ---
Story: My story description
  As a user
  I want to buy something
  So I have stuff

  Scenario: user has money and buys something
    Given a user has 100 dollars
etc...


-- Ruby file  mystory.rb --
require File.join(File.dirname(__FILE__), "spec_helper")

steps_for(:my_steps) do
  Given...
  When...
  Then...
  etc...
end

with_steps_for :my_steps do
  run File.expand_path(__FILE__).gsub(".rb",".story")
end


Now for the non-plain text stories is it this? (splitting into
separate files is a YMMV thing)

--- mystory.rb ---
require File.join(File.dirname(__FILE__), "spec_helper")

steps_for(:my_steps) do
  Given...
  When...
  Then...
  etc...
end

Story "my story description",
  %(As a thing
    I want to be able to dp something clever
    So that I get paid), :steps_for => :my_steps do

  Scenario "my scenario1" do
    Given etc
 end

end


Thanks for any pointers here.

Jim


More information about the rspec-users mailing list