Skip to content

Instantly share code, notes, and snippets.

@drewdeponte
Created December 27, 2012 02:07
Show Gist options
  • Save drewdeponte/4384850 to your computer and use it in GitHub Desktop.
Save drewdeponte/4384850 to your computer and use it in GitHub Desktop.
class DrewTest
def initialize
@name = self.class.build_name
end
def self.build_name
return "bar"
end
end
describe DrewTest do
describe "#initialize" do
it "should build the name" do
DrewTest.should_receive(:build_name)
DrewTest.new
end
it "should set the name instance variable to the built name" do
DrewTest.stub(:build_name).and_return("hoopty")
obj = DrewTest.new
obj.instance_variable_get("@name").should == "hoopty"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment