[rspec-users] first cut at blockless given/when/then

David Chelimsky dchelimsky at gmail.com
Thu Oct 18 12:42:55 EDT 2007


On 10/18/07, Pat Maddox <pergesu at gmail.com> wrote:
> step_matchers("arithmetic") do
>  given_matcher("an addend of $addend") do |addend|
>    @adder ||= Adder.new
>    @adder << addend.to_i
>  end
>
>  when_matcher("they are added") do
>    @sum = @adder.sum
>  end
>
>  then_matcher("the sum should be $sum") do |sum|
>    @sum.should == sum.to_i
>  end
> end
>
> That allows you to do something like
>
> Story: Adding numbers
>   uses arithmetic vocabulary
>   ...
>
>
> or something along those lines.

I like the idea of mapping a story to a vocabulary. I just don't like
doing it in the story text itself - seems more dev-facing than
customer-facing. But perhaps the notion of vocabulary is a good thing
to have front and center to help the customer understand the
constraints of what can be written. Need to think about that some
more.

Cheers,
David


More information about the rspec-users mailing list