Re: [rspec-users] Database clearing

2008-09-20 Thread Matt Wynne
On 20 Sep 2008, at 01:59, Scott Taylor wrote: There's another approach though that I haven't tried yet. One of the guys I work with truncates all the tables in the db before every example. He says this runs as fast or faster than transactional fixtures, and has the added benefit of NOT being

Re: [rspec-users] Database clearing

2008-09-20 Thread Todd Tyree
> We have a few lines of code in our features steps/env.rb that does this > > 1. patch AR to stash each AR object created in an array > 2. in an After do block, call destroy on each of those objects. > > We can probably share if anyone would like to see this. > > Please! Best, Todd ___

Re: [rspec-users] Database clearing

2008-09-20 Thread Scott Taylor
On Sep 20, 2008, at 6:31 AM, Matt Wynne wrote: On 20 Sep 2008, at 01:59, Scott Taylor wrote: There's another approach though that I haven't tried yet. One of the guys I work with truncates all the tables in the db before every example. He says this runs as fast or faster than transactio

Re: [rspec-users] Database clearing

2008-09-20 Thread Todd Tyree
Ok, here's what I've come up with on the spur of the moment (goes in spec_helper.rb): config.after(:each) do result = ActiveRecord::Base.connection.execute('SHOW TABLES;') while table = result.fetch_row # Or whatever you think is appropriate. next if table.index('schema_migrat

Re: [rspec-users] Database clearing

2008-09-20 Thread Pat Maddox
"Todd Tyree" <[EMAIL PROTECTED]> writes: > Ok, here's what I've come up with on the spur of the moment (goes in > spec_helper.rb): > > config.after(:each) do > result = ActiveRecord::Base.connection.execute('SHOW TABLES;') > while table = result.fetch_row > # Or whatever you think i

Re: [rspec-users] Database clearing

2008-09-20 Thread Matt Wynne
On 20 Sep 2008, at 11:33, Todd Tyree wrote: We have a few lines of code in our features steps/env.rb that does this 1. patch AR to stash each AR object created in an array 2. in an After do block, call destroy on each of those objects. We can probably share if anyone would like to see thi

Re: [rspec-users] Database clearing

2008-09-20 Thread Mark Wilden
Just to be clear, these methods of truncating tables or remembering rows to delete are only useful in the presence of fixtures? Otherwise, the standard transactional support is sufficient and (probably) faster, right? (if for no other reason because it's all handled deep in the bowels of the db).

Re: [rspec-users] Database clearing

2008-09-20 Thread Scott Taylor
On Sep 20, 2008, at 8:08 AM, Todd Tyree wrote: Ok, here's what I've come up with on the spur of the moment (goes in spec_helper.rb): config.after(:each) do result = ActiveRecord::Base.connection.execute('SHOW TABLES;') while table = result.fetch_row # Or whatever you think is

Re: [rspec-users] Database clearing

2008-09-20 Thread Pat Maddox
"Mark Wilden" <[EMAIL PROTECTED]> writes: > Just to be clear, these methods of truncating tables or remembering rows to > delete are only useful in the presence of fixtures? Otherwise, the standard > transactional support is sufficient and (probably) faster, right? (if for no > other reason becaus

Re: [rspec-users] Database clearing

2008-09-20 Thread Ben Mabey
Todd Tyree wrote: > Ok, here's what I've come up with on the spur of the moment (goes in > spec_helper.rb): > > config.after(:each) do > result = ActiveRecord::Base.connection.execute('SHOW TABLES;') > while table = result.fetch_row > # Or whatever you think is appropriate. > n

Re: [rspec-users] Database clearing

2008-09-20 Thread Scott Taylor
On Sep 20, 2008, at 7:18 PM, Ben Mabey wrote: Todd Tyree wrote: Ok, here's what I've come up with on the spur of the moment (goes in spec_helper.rb): config.after(:each) do result = ActiveRecord::Base.connection.execute('SHOW TABLES;') while table = result.fetch_row # Or whatever y

Re: [rspec-users] Database clearing

2008-09-20 Thread Ben Mabey
Scott Taylor wrote: > > On Sep 20, 2008, at 7:18 PM, Ben Mabey wrote: > >> Todd Tyree wrote: >>> Ok, here's what I've come up with on the spur of the moment (goes in >>> spec_helper.rb): >>> >>> config.after(:each) do >>>result = ActiveRecord::Base.connection.execute('SHOW TABLES;') >>>whil

Re: [rspec-users] Database clearing

2008-09-20 Thread Ben Mabey
Ben Mabey wrote: > Scott Taylor wrote: > >> On Sep 20, 2008, at 7:18 PM, Ben Mabey wrote: >> >> >>> Todd Tyree wrote: >>> Ok, here's what I've come up with on the spur of the moment (goes in spec_helper.rb): config.after(:each) do result = ActiveRecord::Ba

Re: [rspec-users] Database clearing

2008-09-20 Thread Scott Taylor
On Sep 20, 2008, at 8:53 PM, Ben Mabey wrote: Ben Mabey wrote: Scott Taylor wrote: On Sep 20, 2008, at 7:18 PM, Ben Mabey wrote: Todd Tyree wrote: Ok, here's what I've come up with on the spur of the moment (goes in spec_helper.rb): config.after(:each) do result = ActiveRecord::Bas