----- Original Message ----
> From: David Chelimsky <dchelim...@gmail.com>
> Shared examples don't support parameterization, but macros do. Try
> something like this:
>
> module Macros
> def shows_yearly_archive_for(requests={})
[...]
> end
> end
>
> describe SomeController do
> extend Macros
> shows_yearly_archive_for :index => :get
> end
Nice. This must be newish (I see it in book beta4 - good!). I'd been using
callbacks defined in the example group next to it_should_behave_like() to get
any relevant parameters. A bit icky, I'll admit. So I can just pass the
details from the callback directly to the macro, when I port it/them. Sweet.
I've been using a pattern for my shared example groups, similar to one I
correlate (erroneously?) to a Ben Mabey post. The original pattern: do_foo(),
where foo is get, post, whatever and the shared example probes the calling
example group to find which one is relevant.
My variation is do_action(), where the example group directly defines
do_action() in whatever way is suitable to the example group (using instance
variables set by before blocks, etc). This method could be defined usefully by
either a Controller example group or a Model example group.
I feel like even when using macros, I'd want to continue using my do_action()
pattern. But maybe I have a hammer and so I'm looking for a nail.
Is there another approach that gives different/better value when using macros?
Thanks,
Randy
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users