On Nov 27, 2007, at 12:23 PM, Scott Taylor wrote:
> Or, you could also do some sort of behaviour verification. What do
> you expect this DatabaseMapper setup should do? Why is it in your
> code? If you can answer these questions, then you can probably write
> a test for it (but without stubbing)
Boy, don't I wish. Not my code, but I'd like to have a spec before I
submit a patch. The DataMapper project is doing a great job of
keeping specs parallel to their development, but the one thing they
do is prepopulate a sqlite database prior to running all the tests.
The bug I'm submitting a patch for is mysql-specific, and I'm at a
loss how to un-sqliteize the environment without breaking all the
other tests.
I know tests should run in isolation, but again, not my specification
suite. They optimized for quick runs of the specs, I guess. So,
rather than spec the behavior, I'm opting to check whether setup is
called with the right parameters. What I'd prefer is to do something
more like:
DataMapper::Database[:default].socket.should eql('/tmp/mysql.sock')
which is the *behavior* I want. I'm not seeing how to get from here
to there.
The following is pretty much where I'm at, except that the
expectation for :setup has a with(). I put out a ping to the
DataMapper list, but so far no responses.
module DataMapper
class Database
end
end
describe "setting up datamapper from a database.yml" do
it "should look for database.yml" do
File.stub!(:exists?).and_return(true)
YAML.stub!(:load_file).and_return(
"development"=>{
"socket"=>"/tmp/mysql.sock",
"username"=>"root",
"adapter"=>"mysql",
"password"=>nil,
"database"=>"fakedb_development"}
)
DataMapper::Database.should_receive(:setup)
Kernel::load File.dirname(__FILE__) + '/../lib/data_mapper.rb'
end
end
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users