Created
December 30, 2011 21:26
-
-
Save kbarber/1541536 to your computer and use it in GitHub Desktop.
mocking mysql database connections
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
#!/usr/bin/env rspec | |
require 'mocha' | |
require 'mysql' | |
describe "foo" do | |
it "should mock mysql query" do | |
mock_mysql = mock("Mysql") | |
Mysql.expects(:new).returns(mock_mysql) | |
mock_mysql.expects(:query).with("create database foo") | |
db = Mysql.new("localhost", "root", "this is not the password") | |
db.query("create database foo") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment