<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
I have to agree with David. (It's in the contract ;)<br>
<br>
Scenarios are reusable as steps in order to chain multiple scenarios
together (to describe the various coarse-grained stages of a workflow,
state machine or wizard, for example).<br>
<br>
At an example level it is just confusing. I've noticed that if I find
myself wanting to do that, it's an indication that the objects are too
tightly coupled or dependent on one another. There is usually a cleaner
abstraction in there waiting to be discovered that will mean you don't
need to chain examples in this way.<br>
<br>
fwiw GivenScenario was introduced into JBehave to work around the
constraint that scenarios were only allowed to be of the form
Given/When/Then in the early days. Then we relaxed scenarios to allow
mixing up steps in any order (given.. when.. then.. when.. then..)
which made them read much more naturally. GivenScenarios aren't used
much now other than in the specific situations I described above (state
machines, etc).<br>
<br>
Cheers,<br>
Dan<br>
<br>
David Chelimsky wrote:
<blockquote
cite="mid:57c63afe0709211303p4592f42ci3a7b94058d84657e@mail.gmail.com"
type="cite">
<pre wrap="">On 9/21/07, Yurii Rashkovskii <a class="moz-txt-link-rfc2396E" href="mailto:yrashk@gmail.com"><yrashk@gmail.com></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Sure! But they are not the same stuff. What I was looking for is
it "should do #1" do
...
end
it "should do X after #1" do
given_it "should do #1"
should do_x
end
it "should do Y after #1" do
given_it "should do #1"
should do_y
end
it "should do Z after #1 Y" do
given_it "should do Y after #1"
should do_z
end
</pre>
</blockquote>
<pre wrap=""><!---->
Sorry mate - that just seems like endless confusion - the examples
should never rely on each other that way - different animal from
scenarios that involve steps.
</pre>
<blockquote type="cite">
<pre wrap="">Or am I missing somethiing?
On Sep 21, 2007, at 10:49 PM, David Chelimsky wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Have you seen shared behaviours?
On 9/21/07, Yurii Rashkovskii <a class="moz-txt-link-rfc2396E" href="mailto:yrashk@gmail.com"><yrashk@gmail.com></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hello,
Just decided to check whether I am doing something that makes sense
or not. I was thinking about how cool would it be to re-use examples
(just like we reuse story scenarios with GivenScenario). I was not
sure if this possibility already exists in rspec (and, honestly, was
lazy to check), so I have created this helper:
def given_it(name)
example_definition = behaviour.example_definitions.find{|i|
i.description == name }
instance_eval(&example_definition.example_block)
end
so it is possible to write things like
it "should do something after another action" do
given_it "should successfully do another action"
do_something.should be_fine
end
Is there anything already in rspec that allows me to do the same
stuff? Or was it a bad idea at all?
Yurii.
_______________________________________________
rspec-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a>
<a class="moz-txt-link-freetext" href="http://rubyforge.org/mailman/listinfo/rspec-users">http://rubyforge.org/mailman/listinfo/rspec-users</a>
</pre>
</blockquote>
<pre wrap="">_______________________________________________
rspec-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a>
<a class="moz-txt-link-freetext" href="http://rubyforge.org/mailman/listinfo/rspec-users">http://rubyforge.org/mailman/listinfo/rspec-users</a>
</pre>
</blockquote>
<pre wrap="">_______________________________________________
rspec-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a>
<a class="moz-txt-link-freetext" href="http://rubyforge.org/mailman/listinfo/rspec-users">http://rubyforge.org/mailman/listinfo/rspec-users</a>
</pre>
</blockquote>
<pre wrap=""><!---->_______________________________________________
rspec-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a>
<a class="moz-txt-link-freetext" href="http://rubyforge.org/mailman/listinfo/rspec-users">http://rubyforge.org/mailman/listinfo/rspec-users</a>
</pre>
</blockquote>
<br>
</body>
</html>