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

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 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 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
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 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 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 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 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 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 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 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
> 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 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-19 Thread Scott Taylor
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 in a transaction, which means that if he actua

Re: [rspec-users] Database clearing

2008-09-19 Thread Todd Tyree
On Fri, Sep 19, 2008 at 5:34 PM, Pat Maddox <[EMAIL PROTECTED]> wrote: > No, that is not correct. Here's how transactional fixtures work: > > 1. Before all specs run, load the fixtures into the database > 2. Start a transaction. Run the first spec > 3. Rollback transaction > 4. Start another tr

Re: [rspec-users] Database clearing

2008-09-19 Thread Pat Maddox
"Todd Tyree" <[EMAIL PROTECTED]> writes: > I'm seeing something strange and was just wondering if someone can confirm my > assumptions for me: > > I have user model with a number of specs: some of them use fixtures and some > of them don't. Today, while talking someone through some specs that ne

Re: [rspec-users] Database clearing

2008-09-19 Thread Todd Tyree
On Fri, Sep 19, 2008 at 3:42 PM, Mark Wilden <[EMAIL PROTECTED]> wrote: > I don't know the exact mechanism, but if we want a table to be emply that > might have had fixtures loaded into it at some point, we delete_all in > before(). It seems to me that if you have fixtures, they would be loaded >

Re: [rspec-users] Database clearing

2008-09-19 Thread Mark Wilden
On Fri, Sep 19, 2008 at 6:22 AM, Todd Tyree <[EMAIL PROTECTED]> wrote: > > I have user model with a number of specs: some of them use fixtures and > some of them don't. Today, while talking someone through some specs that > needed developming, I noticed that the fixtures always seemed to be > lo

Re: [rspec-users] Database clearing

2008-09-19 Thread Todd Tyree
> Does your spec_helper file have this: > > Spec::Runner.configure do |config| > config.use_transactional_fixtures = true > end > Yes. > > Also, what versions of rspec and rails are you using? 1.1.4 and 2.1.0 Cheers, Todd ___ rspec-users mailing l

Re: [rspec-users] Database clearing

2008-09-19 Thread Todd Tyree
Sorry, hit the enter key prematurely, That 'bit more concise' bit of the spec should read: describe User, "description" do it "should not show emails" do User.all.should be_blank # Or, to be a bit more concise: User.all.select{|u| u.email == '[EMAIL PROTECTED] <[EMAIL PROTECTED]>'}.

Re: [rspec-users] Database clearing

2008-09-19 Thread David Chelimsky
On Fri, Sep 19, 2008 at 8:22 AM, Todd Tyree <[EMAIL PROTECTED]> wrote: > I'm seeing something strange and was just wondering if someone can confirm > my assumptions for me: > > I have user model with a number of specs: some of them use fixtures and > some of them don't. Today, while talking someo

[rspec-users] Database clearing

2008-09-19 Thread Todd Tyree
I'm seeing something strange and was just wondering if someone can confirm my assumptions for me: I have user model with a number of specs: some of them use fixtures and some of them don't. Today, while talking someone through some specs that needed developming, I noticed that the fixtures alway