On 1/24/07, Christian Neukirchen <chneukirchen / gmail.com> wrote:
> "David Chelimsky" <dchelimsky / gmail.com> writes:
>
> > On 1/24/07, Christian Neukirchen <chneukirchen / gmail.com> wrote:
> >> "David Chelimsky" <dchelimsky / gmail.com> writes:
> >>
> >> > That said, you can include modules and get reuse that way:
> >> >
> >> > module SomeHelperMethodsUsefulAcrossContexts
> >> > end
> >> >
> >> > context "some context" do
> >> >  include SomeHelperMethodsUsefulAcrossContexts
> >> > end
> >> >
> >> > I'd be surprised if test/spec doesn't already support this out of the box.
> >>
> >> It works exactly the same in test/spec.
> >
> > Glad to hear it. Do you have any feeling about which approach to reuse
> > you personally prefer? Nested contexts or included modules?
>
> As said, nesting is purely for organizational and namespacing purposes.
> I use modules.

Interesting. I thought it was for context state sharing like this:

context "a User" do
  setup do
    user = User.new
  end

  context "with a valid email address" do
    setup do
      user.email = "a / b.com"
    end
    ...
  end

  context "with an invalid email address" do
    setup do
      user.email = "this / is.not.correctly.formatted"
    end
    ...
  end
end

This leads us quickly down a path in which you have to look up a chain
of several setup methods to understand failures.

If it's just a matter of namespacing for reporting/organization that's
kind of interesting.

David

>
> --
> Christian Neukirchen  <chneukirchen / gmail.com>  http://chneukirchen.org
>
>