[Rspec-devel] Patch that allows method definitions inside of a context

Brian Takita brian.takita at gmail.com
Mon Jul 10 01:51:10 EDT 2006


>
> Are the methods scoped to the context?


Yes.

Is there a clean way of sharing them across contexts?
>
If you have the latest version of the Trunk, you can either use:

context "Should include SomeModule" do
  include SomeModule
end

or

context "Should inherit SomeClass" do
  inherit SomeClass
end

Ruby's inheritance and mixin rules apply to contexts.

On 7/9/06, Lachie <lachiec at gmail.com> wrote:
>
> +1
>
> Are the methods scoped to the context? Is there a clean way of sharing
> them across contexts?
>
> On 7/10/06, aslak hellesoy <aslak.hellesoy at gmail.com> wrote:
> > Great stuff Brian - you're a metaprogramming whiz!
> >
> > I'd like to apply this patch, what do you others think?
> >
> > Aslak
> >
> > On 7/9/06, Brian Takita < brian.takita at gmail.com> wrote:
> > > Hello,
> > >
> > > I submitted a patch that allows you to define methods inside of the
> context
> > > block rather than inside of the setup method block.
> > > http://rubyforge.org/tracker/index.php?group_id=797&atid=3151
> > >
> > > For example, this patch allows:
> > > require File.dirname(__FILE__) + '/../lib/spec'
> > >
> > > context "Rspec allow you to define custom methods" do
> > >  specify "Rspec should allow you to define methods" do
> > >
> > >  a_method
> > >  @a_method_called.should.be true
> > >  end
> > >
> > >  def a_method
> > >  @a_method_called = true
> > >  end
> > > end
> > > This patch also does not break the behaviour where methods can be
> defined
> > > inside of the setup block.
> > >
> > > Thank you,
> > > Brian Takita
> > >
> > > _______________________________________________
> > > Rspec-devel mailing list
> > > Rspec-devel at rubyforge.org
> > > http://rubyforge.org/mailman/listinfo/rspec-devel
> > >
> > >
> > _______________________________________________
> > Rspec-devel mailing list
> > Rspec-devel at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-devel
> >
>
>
> --
> Lachie
> http://lachie.info/
> http://www.flickr.com/photos/lachie/
> _______________________________________________
> Rspec-devel mailing list
> Rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-devel/attachments/20060709/510161bc/attachment.html 


More information about the Rspec-devel mailing list