[rspec-devel] [ rspec-Feature Requests-8654 ] Aspects

noreply at rubyforge.org noreply at rubyforge.org
Fri May 11 18:24:16 EDT 2007


Feature Requests item #8654, was opened at 2007-02-14 07:07
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3152&aid=8654&group_id=797

Category: runner module
Group: None
Status: Open
Priority: 3
Submitted By: Yurii Rashkovskii (yrashk)
Assigned to: Nobody (None)
Summary: Aspects

Initial Comment:
Specifications become a bit messy in large applications. What if implementing aspects for rspec?

context "New Document instance" do

  setup do
    @document = Document.new
  end 

   aspect "versioning" do

    specify "should have no versions" do
     @document.should_have(0).versions
    end

   end

   aspect "printing" do
     aspect "pdf" do
       ...
     end
   end

 end

New Document instance
- (versioning) should have no versions
- (printing/pdf) ...

Initial implementation (requires ActiveSupport, but could be easily ported to pure Ruby) and more details are available at http://rashkovskii.com/articles/2007/2/13/rspec-aspects

----------------------------------------------------------------------

>Comment By: David Chelimsky (dchelimsky)
Date: 2007-05-11 22:24

Message:
"Facet" is brilliant. Thanks.

----------------------------------------------------------------------

Comment By: Wincent Colaiuta (wincent)
Date: 2007-03-19 13:40

Message:
> Any other suggestions? I want to come up w/ the right name
> before we add this.

"Facet"?

----------------------------------------------------------------------

Comment By: David Chelimsky (dchelimsky)
Date: 2007-03-19 12:56

Message:
Agreed that sub_context is the wrong name, and "aspect" WOULD be a great name if it didn't evoke Aspect Oriented Programming.

Any other suggestions? I want to come up w/ the right name before we add this.

----------------------------------------------------------------------

Comment By: Yurii Rashkovskii (yrashk)
Date: 2007-02-16 12:57

Message:
Also, I think that sub_context isn't good name for aspect. In my understanding 
aspects to be _quite_ orthogonal to context. It's kind of protocol in Smalltalk, or 
something like that.

----------------------------------------------------------------------

Comment By: Yurii Rashkovskii (yrashk)
Date: 2007-02-16 12:49

Message:
David,

basically your idea about nested blocks with arbitrary names is nice, but I 
foresee one problem. My current implementation supports nested aspects 
and joins their names like "(versioning/backup)" for nested versioning -> 
backup aspects. WDYT?

I will surely be able to rework any of my proof-of-concept implementation of 
rspec extensions as a patch with tests once it will be agreed with rspec 
maintainers.

----------------------------------------------------------------------

Comment By: David Chelimsky (dchelimsky)
Date: 2007-02-14 14:02

Message:
Thanks Yurii. This is pretty sweet.

Please take a look at http://rubyforge.org/tracker/index.php?func=detail&aid=8126&group_id=797&atid=3152.

The direction that one is going is that we'd have nested specify blocks that you could invoke using arbitrary names (like "sub_context" or "aspect"). You'd end up being able to do exactly what you propose in your specs, but you'd have to wrap "versioning" in parens to get the output you're looking for:

context "New Document instance" do
  aspect "(versioning)" do
    specify "should have no versions" do
      ...
      
WDYT?

Also, if you're going to submit implementations, please do so in the form of patches here in the this Tracker. Not to suggest that you shouldn't put it on your blog also, but it would be better to have the history of this conversation in one place.

Lastly, regardless of whether we use your suggestion or what I've just described, I'd recommend coming up with another word besides "aspect" to avoid confusion w/ Aspect Oriented Programming.

Cheers,
David


----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3152&aid=8654&group_id=797


More information about the rspec-devel mailing list