Re: [rspec-users] Specing a rails monkey patch

2008-07-23 Thread Mikel Lindsaar
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

Re: [rspec-users] Specing a rails monkey patch

2008-07-23 Thread Mikel Lindsaar
On Mon, Jul 21, 2008 at 6:38 PM, Keith McDonnell <[EMAIL PROTECTED]> wrote: > I /could/ use an SQL cursor but: > I don't know if these are valid reasons however :) The only thing you gain with a direct SQL cursor is the guarantee of hitting each row exactly once without having to pull down all the

Re: [rspec-users] Specing a rails monkey patch

2008-07-21 Thread Keith McDonnell
Hi Mikel, Thanks for the feedback. Much appreciated. >I'm using cursors to walk a table with close to a million rows at times. > >I am just wrapping the action in a transaction and then declaring the >cursor within the transaction and then walking the table with a >find_by_sql with an SQL fetch

Re: [rspec-users] Specing a rails monkey patch

2008-07-19 Thread Mikel Lindsaar
On Fri, Jul 18, 2008 at 8:11 PM, Keith McDonnell <[EMAIL PROTECTED]> wrote: > I wrote an ActiveRecord extension to emulate a db cursor: > http://pastie.org/236367 > As you can see, the spec doesn't really ensure that the records are fetched > in chunks. I'd like to mock the call to AR find and ensu

[rspec-users] Specing a rails monkey patch

2008-07-18 Thread Keith McDonnell
Hi all, I wrote an ActiveRecord extension to emulate a db cursor: http://pastie.org/236367 As you can see, the spec doesn't really ensure that the records are fetched in chunks. I'd like to mock the call to AR find and ensure that it's called with an incrementing offset. Any advice? Keith