Skip to content

Instantly share code, notes, and snippets.

@arwagner
Created November 15, 2011 02:36
Show Gist options
  • Save arwagner/1365959 to your computer and use it in GitHub Desktop.
Save arwagner/1365959 to your computer and use it in GitHub Desktop.
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