[rspec-devel] [ rspec-Feature Requests-8654 ] Aspects
noreply at rubyforge.org
noreply at rubyforge.org
Fri Feb 16 07:49:05 EST 2007
Feature Requests item #8654, was opened at 2007-02-14 09: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: Yurii Rashkovskii (yrashk)
Date: 2007-02-16 14: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 16: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