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

2010-08-01 Thread Myron Marston
OK, I tried to implement #module_exec on ruby 1.8.6, and here's what I came up with: http://github.com/myronmarston/rspec-core/commit/364f20ebd5b7d9612227cb6e86a6e8c8c2e9931e It works (at least in the sense that it allows the specs and features I added in the previous commits in that branch to pa

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

2010-08-01 Thread Myron Marston
> If we do this, we should use module_exec for both blocks so they both get the > same arguments. I actually find the use of this to be a bit confusing: [:foo, :bar].each do |arg| it_should_behave_like "Something", arg do |a| # The value of the param is already bound to arg and now it's bo

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

2010-08-01 Thread David Chelimsky
On Aug 1, 2010, at 5:12 PM, Ashley Moran wrote: > > On 1 Aug 2010, at 3:43 PM, David Chelimsky wrote: > >> shared_examples_for "blah" do |a,b| >> ... >> end >> >> it_should_behave_like "blah", 1, 2 >> >> That wouldn't have worked with the old implementation, but it would work >> perfectly we

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

2010-08-01 Thread David Chelimsky
On Aug 1, 2010, at 5:39 PM, Myron Marston wrote: >> Seems like your mental model is that of a customization block being a >> subclass or re-opening of the shared block. What you say makes sense in that >> model, but that's not the same model I have. > > My mental model is indeed that the custom

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

2010-08-01 Thread Myron Marston
> Seems like your mental model is that of a customization block being a > subclass or re-opening of the shared block. What you say makes sense in that > model, but that's not the same model I have. My mental model is indeed that the customization block is like a subclass. I'm not sure where I g

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

2010-08-01 Thread Ashley Moran
On 1 Aug 2010, at 3:43 PM, David Chelimsky wrote: > shared_examples_for "blah" do |a,b| > ... > end > > it_should_behave_like "blah", 1, 2 > > That wouldn't have worked with the old implementation, but it would work > perfectly well now. This would also "just work" with hash-as-keyword-args:

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

2010-08-01 Thread David Chelimsky
On Aug 1, 2010, at 11:40 AM, Myron Marston wrote: >> The particular issue of simple values being used in the docstrings and the >> examples themselves (i.e. exposed to everything in the block scope) could be >> handled like this: >> >> shared_examples_for "blah" do |a,b| >> ... >> end >> >>

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

2010-08-01 Thread Myron Marston
> The particular issue of simple values being used in the docstrings and the > examples themselves (i.e. exposed to everything in the block scope) could be > handled like this: > > shared_examples_for "blah" do |a,b| >   ... > end > > it_should_behave_like "blah", 1, 2 Fantastic idea. I'm sold.

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

2010-08-01 Thread David Chelimsky
On Jul 31, 2010, at 1:06 PM, Myron Marston wrote: >> You can still get the same outcome, but you have to implement it in the >> group like this: > >> unless defined?(:foo) >> def foo; "foo"; end >> end > > Good point--I hadn't thought of that. The one issue I see with it is > that the author

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

2010-08-01 Thread David Chelimsky
On Aug 1, 2010, at 9:43 AM, David Chelimsky wrote: > > On Jul 31, 2010, at 1:06 PM, Myron Marston wrote: > >>> You can still get the same outcome, but you have to implement it in the >>> group like this: >> >>> unless defined?(:foo) >>> def foo; "foo"; end >>> end >> >> Good point--I hadn't t

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

2010-08-01 Thread Ashley Moran
On Jul 31, 2010, at 7:06 pm, Myron Marston wrote: > I think this is a clunky way to essentially pass a parameter to the > shared example group. Better would be something like this: > > it_should_behave_like "something" do > providing :method_name, :foo > end After sleeping on this, I found an