[rspec-devel] merging rbehave into rspec

Dan North dan at tastapod.com
Mon Jul 30 17:18:13 EDT 2007


Hi Brian.

Thanks for the heads-up.

If you're talking about taking the eval magic out of Behaviour, then I 
think we should be ok. Again, although rbehave uses a similar model, it 
needs its own instance_eval magic because of the way it processes 
multiple scenarios within a story.

You're welcome to steal the design - and even factor out common code if 
there is any. It works like this:

Story 'a story', ... do
    # shared code from here ->

    def shared_method
       # ...
    end

    @some_shared_var = 'hello'

    include SomeSharedModule

    # -> to here

    Scenario 'scenario 1' do
       # ...
    end

    Scenario 'scenario 2' do
       # ...
    end
end

For each scenario, it takes an instance of an object (either an Object 
or your own custom class, say a Rails IntegrationTestCase) and 
instance_evals the Story block, but with the Scenario method redefined 
to do nothing. This has the effect of making sure any shared code such 
as support methods are defined or modules included etc. Then it 
instance_evals the Scenario block for that scenario in the same 
instance, which now has access to the support methods, instance vars and 
included modules.

I'm pretty sure the same thing would work for the examples (it-blocks) 
within each describe block, but I haven't looked too closely.

The rbehave stuff will hopefully be in the rspec codebase by the end of 
the week in a new rspec/story module. I should have some time on Friday 
to do this. (The parameterised steps - the Given, When and Then blocks - 
are more devious :)

David is about to push out a new rspec build, so I will hold off 
committing anything until after that, but it should tie in quite nicely 
in terms of timing.

Cheers,
Dan


Brian Takita wrote:
> Sorry, I sent the email too early:
>
> It doesn't look like we will collide too much, though.
>
> On 7/29/07, Brian Takita <brian.takita at gmail.com> wrote:
>   
>> Fyi, I was planning starting the Behaviour refactoring next week. I
>> don't know how this affects the Rbehave integration at this time.
>>
>> It doesn'
>>
>> On 7/27/07, Dan North <dan at tastapod.com> wrote:
>>     
>>>  Hi folks.
>>>
>>>  I've been talking with David Chelimsky and Aslak* about bringing rbehave
>>> and rspec together into a "full stack" BDD framework. The thinking is
>>> roughly this:
>>>
>>>  - rspec is about describing and verifying objects and interactions, at the
>>> code level>  - rbehave is about describing and verifying stories and scenarios, at the
>>> application level
>>>  (from here on I'm calling rspec the object description framework, and
>>> rbehave the story description framework)
>>>
>>>  So here's the plan:
>>>
>>>  - the object and story frameworks keep their own runners - they are
>>> functionally different although they share some common design concepts
>>> (listeners, renderers, etc.)
>>>  - the story framework adopts the object framework's domain vocabulary (so
>>> if rspec calls something a Renderer and rbehave calls the same concept a
>>> Describer, it gets renamed in rbehave to a Renderer)
>>>  - the story framework will reuse any identical concepts from the object
>>> framework (so rbehave will use rspec's PendingException, for example)
>>>  - the story runner becomes part of rspec's core, in a suitable module
>>> namespace
>>>  - all the story runner behaviours are migrated across
>>>  - the rbehave rubyforge project is gutted to simply delegate to the rspec
>>> story framework (this is an interim move to retain compatibility)
>>>
>>>  The near-term objectives are:
>>>
>>>  1) integrate story description behaviour natively into rspec
>>>  2) support description of Rails behaviour at a story/scenario level
>>>
>>>  So:
>>>
>>>  - what do you think?
>>>  - does anyone want to help me?
>>>  - please say yes because I have no idea how to do 2)
>>>
>>>  Thanks,
>>>  Dan
>>>
>>>  * Aslak only has one name - like Cher or Madonna.
>>>
>>> _______________________________________________
>>> rspec-devel mailing list
>>> rspec-devel at rubyforge.org
>>> http://rubyforge.org/mailman/listinfo/rspec-devel
>>>
>>>       
> _______________________________________________
> rspec-devel mailing list
> rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-devel/attachments/20070730/0432597f/attachment-0001.html 


More information about the rspec-devel mailing list