[rbehave-users] Defining blocks only once
dan at tastapod.com
dan at tastapod.com
Wed Jul 18 13:31:27 EDT 2007
Hi Jake.
Each step (given, event or outcome) is stored in a separate hash, so it
doesn't matter if their names collide. However I quite like the idea that
an event in one scenario can become a given in another, so I'm open to the
idea that we could store them all in one place.
On the other hand, have you seen GivenScenario? This allows you to use an
entire scenario as a given to another scenario. You identify it by name:
Scenario "something happens" do
...
end
Scenario "something else happens" do
GivenScenario "something happens"
...
end
There's an example in the game-of-life sample code. Let me know if this
helps, because I would prefer not to put all the different event types in
the same bucket.
Cheers,
Dan
> Hi Dan,
>
> I would like to write an acceptance test for a workflow, and would
> like to do the following:
>
> ~~~~
> require 'rubygems'
> require 'rbehave'
>
> Story "Test for reusing blocks",
> %(As a test writer, I would like to be
> able to reuse blocks i've already defined
> in 'when' for 'given') do
>
> Scenario "1" do
> Given "A" do end
> When "B" do end
> Then "C" do end
> end
>
> Scenario "2" do
> Given "A"
> Given "B"
> When "C"
> Then "D" do end
> end
> end
> ~~~~
> However when I reuse the B block in scenario 2, it's not being recognised.
> Keeping with the DRY principle, is it possible to make all blocks that
> you've defined earlier reusable?
>
> Thanks again,
> Jake
> _______________________________________________
> rbehave-users mailing list
> rbehave-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rbehave-users
>
More information about the rbehave-users
mailing list