[rspec-users] Specing a rails monkey patch

Mikel Lindsaar raasdnil at gmail.com
Wed Jul 23 03:22:36 EDT 2008


Sorry, hit the tab and enter key too soon :)

You'd stub out the model.

class DummyModel
  acts_as_curseable
end

it "should ask the database to set up a transaction" do
  DummyModel.connection.should_receive("BEGIN;").once
  ... then the execution code to make that happen
end

it "should ask the database to set up a cursor" do
  DummyModel.connection.should_receive("DECLARE dummy_model_cursor
CURSOR FOR...;").once
  ... then the execution code to make that happen
end

it "should tell the database to give it another X rows" do
  DummyModel.should_receive(:find_by_sql).with("FETCH 500 FROM
dummy_model_cursor;")
  ... then the execution code to make that happen
end


Hope that sort of starts you off :)

And if you like 'acts_as_curseable' for the plugin name, I want
acknowledgement :D

-- 
http://lindsaar.net/
Rails, RSpec and Life blog....


More information about the rspec-users mailing list