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

Ashley Moran ashley.moran at patchspace.co.uk
Wed Aug 4 04:43:24 EDT 2010


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?  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





More information about the rspec-users mailing list