[rspec-devel] [ rspec-Bugs-13741 ] Helper specs oddities, compared to controller and other specs
noreply at rubyforge.org
noreply at rubyforge.org
Fri Sep 7 05:40:02 EDT 2007
Bugs item #13741, was opened at 2007-09-07 08:05
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=13741&group_id=797
Category: mock module
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Johan Sørensen (johansorensen)
Assigned to: Nobody (None)
Summary: Helper specs oddities, compared to controller and other specs
Initial Comment:
I've always found it odd that helpers called directly in the it() block, and not through an instance of some sort, eg typing
it "should do stuff" do
helper_method.should == "output"
end
and even worse
it "should do stuff" do
mock(:helper_method).and_return("thingies")
#..
end
eg its not obvious at first sight exactly what you're mocking/expecting on, and its very inconsistant to general (non-rails) specs and controller/model specifications, where operate on some object.
Why not mix the helper into a dummy Helper object instead? So we can do:
it "should do stuff" do
helper.mock(:helper_method).and_return("thingies")
helper.other_method.should == "thingies are good"
end
----------------------------------------------------------------------
>Comment By: David Chelimsky (dchelimsky)
Date: 2007-09-07 09:40
Message:
That's a great idea, but a year late.
We could offer up a helper object as an alternative, but I wouldn't want to break any existing helper specs in the process. The only problem there is that it becomes confusing when you're allowed to write things in both ways and then someone else comes in contact with the specs and sees
it "should do stuff" do
helper.mock(:helper_method).and_return("thingies")
other_method.should == "thingies are good"
end
WDYT?
----------------------------------------------------------------------
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=13741&group_id=797
More information about the rspec-devel
mailing list