[rspec-devel] changes to Story Runner steps

David Chelimsky dchelimsky at gmail.com
Wed Oct 24 08:53:47 EDT 2007

On 10/24/07, Josh Chisholm <joshuachisholm at gmail.com> wrote:
> Hi David,
> I don't know if this is still open for discussion, but would it be
> wrong (or possible) to take the first word of the matcher itself to
> determine its type? e.g:
> steps = StepGroup.new do
>   steps do
>      "given my savings account balance is $balance".means do |balance|
>          @savings_account = Account.new(balance.to_f)
>       end
>   end
> end
Possible, yes. Wrong, no. Does that mean we should? Maybe. Maybe not.

First - we'll be doing something more in line with the rest of RSpec
to hide the SpecMatcher class. Dan and I have been batting this around
and I'm leaning towards something like this (Dan, please comment if
you're reading this):

steps_for :accounts do
  Given "my savings account balance is $balance" do |balance|
    @savings_account = Account.new(balance.to_f)

Keep in mind that Ruby stories won't go away, so this means that
whether you're defining steps for a tag (more on that below) or
defining a Story in Ruby, you use the same Given/When/Then syntax.
While it would be sexy to bend String to our will as in your proposal,
I think this consistency is going to be important.

The tags would replace the need for defining subclasses of StepGroup.
In rake-like fashion, we can nest groups of steps like this:

steps_for :interest_bearing_accounts => [:accounts] do
  Given "my interest rate is $rate" { |rate| ... }

Then we could use them like this (not yet - this is all hypothetical):

using_steps_for :login, :navigation, :accounts do
  run 'path/to/story'



More information about the rspec-devel mailing list