[rspec-users] given_it

David Chelimsky dchelimsky at gmail.com
Fri Sep 21 15:49:51 EDT 2007


Have you seen shared behaviours?

On 9/21/07, Yurii Rashkovskii <yrashk at gmail.com> wrote:
> 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
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list