[rspec-users] Evaluating shared example customisation block before shared block

David Chelimsky dchelimsky at gmail.com
Wed Aug 4 07:41:03 EDT 2010


On Aug 4, 2010, at 3:43 AM, Ashley Moran wrote:

> 
> On 4 Aug 2010, at 1:05 AM, David Chelimsky wrote:
> 
>> 
> 
> 
> One other thought I've had is keyword syntax.  While currently I'm writing:
> 
>  it_satisfies_contract "[Entity] Collection:", :children, :child, Child.name
> 
> I prefer keyword arguments, so I'd like to write:
> 
>  it_satisfies_contract "[Entity] Collection:",
>    :children,
>    item_name: "child",
>    class_name: Child.name
> 
> Currently that would mean rewriting the contract like this:
> 
>  contract "[Entity] Collection:" do  |collection_name, options|
> 
>    # ...
> 
>    describe "#{collection_name}" do
>      describe "Helper methods:" do
>        describe "#new_#{options[:item_name]}, #get_#{options[:item_name]}" do
> 
>    # ...
> 
> WDYT about RSpec automatically translating keyword options to methods?

What happens if the shared spec author really wants it to just be a hash? Do you think that's a valid use case?

> They'd need to be defined as singleton class methods and instance methods to have the same availability as block parameters.
> 
> Ash
> 
> -- 
> http://www.patchspace.co.uk/
> http://www.linkedin.com/in/ashleymoran
> 
> 
> 
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users



More information about the rspec-users mailing list