Created
November 15, 2011 02:36
-
-
Save arwagner/1365959 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Application | |
def fact s | |
end | |
end | |
module RFact | |
def fact fact_as_string | |
Application.new.fact fact_as_string | |
end | |
end | |
describe RFact do | |
let(:application) { stub } | |
describe "#fact" do | |
it "should call fact on a new Application object" do | |
cls = Class.new | |
cls.send(:include,Rfact) | |
obj = cls.new | |
Application.should_receive(:new).and_return application | |
application.should_receive(:fact).with("x") | |
obj.fact "x" | |
end | |
it "calling it twice should use the same application object" do | |
cls = Class.new | |
cls.send(:include, RFact) | |
obj = cls.new | |
Application.should_receive(:new).once | |
cls.fact "x" | |
cls.fact "y" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment