Skip to content

Instantly share code, notes, and snippets.

@dcrec1
Created March 29, 2011 22:22
Show Gist options
  • Select an option

  • Save dcrec1/893477 to your computer and use it in GitHub Desktop.

Select an option

Save dcrec1/893477 to your computer and use it in GitHub Desktop.
describe Foo
describe ".setup" do
it "should capture a Mongo connection for the specified environment host" do
Mongo::Connection.stub(:new) { |param| param.should == host }
Foo.setup config, environment
end
end
describe ".connection" do
it "should assign to the Mongo connection the host for the specified environment" do
Foo.setup(config, environment).connection.host.should == host
end
end
end
describe Foo
let ...
describe ".setup" do
it "should init a new Mongo connection for the specified environment host" do
Mongo::Connection.should_receive(:new).with(host)
Foo.setup config, :test
end
end
describe ".connection" do
it "should return the created Mongo connection on setup" do
Mongo::Connection.stub(:new).and_return(connection)
Foo.setup config, :test
Foot.connection.should == connection
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment