Greg Hauptmann
2008-Nov-06 09:42 UTC
[rspec-users] anyone able to explain logic behind "rake spec" startup (e.g. db:test:prepare => abort_if_pending_migration => invoke environment => etc etc)
anyone able to explain logic behind "rake spec" startup? i.e. the below steps & why things occur when they do Macintosh-2:myequity greg$ rake spec --trace (in /Users/greg/source/myequity) ** Invoke spec (first_time) ** Invoke db:test:prepare (first_time) ** Invoke db:abort_if_pending_migrations (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:abort_if_pending_migrations ** Execute db:test:prepare ** Invoke db:test:load (first_time) ** Invoke db:test:purge (first_time) ** Invoke environment ** Execute db:test:purge ** Execute db:test:load ** Invoke db:schema:load (first_time) ** Invoke environment ** Execute db:schema:load ** Execute spec <cut> thanks
Hongli Lai
2008-Nov-06 12:01 UTC
[rspec-users] anyone able to explain logic behind "rake spec" startup (e.g. db:test:prepare => abort_if_pending_migration => invoke environment => etc etc)
Greg Hauptmann wrote:> anyone able to explain logic behind "rake spec" startup? i.e. the > below steps & why things occur when they do > > Macintosh-2:myequity greg$ rake spec --trace > (in /Users/greg/source/myequity) > ** Invoke spec (first_time) > ** Invoke db:test:prepare (first_time) > ** Invoke db:abort_if_pending_migrations (first_time) > ** Invoke environment (first_time) > ** Execute environment > ** Execute db:abort_if_pending_migrations > ** Execute db:test:prepare > ** Invoke db:test:load (first_time) > ** Invoke db:test:purge (first_time) > ** Invoke environment > ** Execute db:test:purge > ** Execute db:test:load > ** Invoke db:schema:load (first_time) > ** Invoke environment > ** Execute db:schema:load > ** Execute spec > <cut>''spec'' depends on ''db:test:prepare''. ''db:test:prepare'' runs any pending migrations on your development database, and copies the schema structure to the test database. This is to keep the development database''s structure and the test database''s structure in sync. Almost everything you see here is invoked by ''db:test:preare''.
Matt Wynne
2008-Nov-06 15:31 UTC
[rspec-users] anyone able to explain logic behind "rake spec" startup (e.g. db:test:prepare => abort_if_pending_migration => invoke environment => etc etc)
If you want to speed things up, just run spec spec. That will work fine unless you have pending migrations that affect your specs. On 6 Nov 2008, at 12:01, Hongli Lai wrote:> Greg Hauptmann wrote: >> anyone able to explain logic behind "rake spec" startup? i.e. the >> below steps & why things occur when they do >> Macintosh-2:myequity greg$ rake spec --trace >> (in /Users/greg/source/myequity) >> ** Invoke spec (first_time) >> ** Invoke db:test:prepare (first_time) >> ** Invoke db:abort_if_pending_migrations (first_time) >> ** Invoke environment (first_time) >> ** Execute environment >> ** Execute db:abort_if_pending_migrations >> ** Execute db:test:prepare >> ** Invoke db:test:load (first_time) >> ** Invoke db:test:purge (first_time) >> ** Invoke environment >> ** Execute db:test:purge >> ** Execute db:test:load >> ** Invoke db:schema:load (first_time) >> ** Invoke environment >> ** Execute db:schema:load >> ** Execute spec >> <cut> > > ''spec'' depends on ''db:test:prepare''. ''db:test:prepare'' runs any > pending migrations on your development database, and copies the > schema structure to the test database. This is to keep the > development database''s structure and the test database''s structure > in sync. > > Almost everything you see here is invoked by ''db:test:preare''. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
Mark Wilden
2008-Nov-06 15:36 UTC
[rspec-users] anyone able to explain logic behind "rake spec" startup (e.g. db:test:prepare => abort_if_pending_migration => invoke environment => etc etc)
On Thu, Nov 6, 2008 at 4:01 AM, Hongli Lai <hongli at plan99.net> wrote:> <cut> >> > > ''spec'' depends on ''db:test:prepare''. ''db:test:prepare'' runs any pending > migrations on your development database, and copies the schema structure to > the test database. This is to keep the development database''s structure and > the test database''s structure in sync. > > db:test:prepare does not run migrations. It simply checks whether there areany pending migrations and aborts if there are. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081106/9f2ff66f/attachment.html>
Mark Wilden
2008-Nov-06 16:07 UTC
[rspec-users] anyone able to explain logic behind "rake spec" startup (e.g. db:test:prepare => abort_if_pending_migration => invoke environment => etc etc)
On Thu, Nov 6, 2008 at 7:31 AM, Matt Wynne <matt at mattwynne.net> wrote:> If you want to speed things up, just run spec spec. That will work fine > unless you have pending migrations that affect your specs.Or if you have migrations that were applied to the dev db, but you haven''t run db:test:prepare yet. I still get bitten by that. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081106/ccf8020a/attachment.html>
Greg Hauptmann
2008-Nov-06 21:07 UTC
[rspec-users] anyone able to explain logic behind "rake spec" startup (e.g. db:test:prepare => abort_if_pending_migration => invoke environment => etc etc)
I''m still a bit confused - I''ll try to be more specific in questions: * rake db:test:prepare - Check for pending migrations and load the test schema ==> Q1. DOES NOT RUN IN PENDING MIGRATIONS TO TEST DATABASE? ==> Q2. RE TEST SCHEMA - ARE THE MIGRATIONS USE TO CREATE THE DATABASE OR THE DEVELOPMENT SCHEMA FILE??? ==> Q3. WHY DOES IT HAVE TO BE CALLED MORE THAN ONCE? * rake db:test:load - Recreate the test database from the current schema.rb ==> Q4. WHY DO WE NEED TO LOAD FROM THE SCHEMA RATHER THAN MIGRATIONS? IS IT TO AVOID ANY DATA BEING LOADED BY MIGRATIONS FOR THE TEST DATABASE? ==> Q5. WHY IS IT RUN MULTIPLE TIMES? * rake db:test:purge - Empty the test database => Q6. WHY IS IT RUN MULTIPLE TIMES? => Q7. DOES IT DROP TABLES ALSO? tks Confused :) On Fri, Nov 7, 2008 at 2:07 AM, Mark Wilden <mark at mwilden.com> wrote:> On Thu, Nov 6, 2008 at 7:31 AM, Matt Wynne <matt at mattwynne.net> wrote: > >> >> If you want to speed things up, just run spec spec. That will work fine >> unless you have pending migrations that affect your specs. > > Or if you have migrations that were applied to the dev db, but you haven''t > run db:test:prepare yet. I still get bitten by that. > > ///ark > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Mark Wilden
2008-Nov-06 22:13 UTC
[rspec-users] anyone able to explain logic behind "rake spec" startup (e.g. db:test:prepare => abort_if_pending_migration => invoke environment => etc etc)
On Thu, Nov 6, 2008 at 1:07 PM, Greg Hauptmann < greg.hauptmann.ruby at gmail.com> wrote:> I''m still a bit confused - I''ll try to be more specific in questions: > > * rake db:test:prepare - Check for pending migrations and load the test > schema > ==> Q1. DOES NOT RUN IN PENDING MIGRATIONS TO TEST DATABASE? >Correct. It runs no migrations, period. It will abort if there are pending migrations for the development database.> ==> Q2. RE TEST SCHEMA - ARE THE MIGRATIONS USE TO CREATE THE > DATABASE OR THE DEVELOPMENT SCHEMA FILE??? >The development schema file, which db:test:prepare creates.> ==> Q3. WHY DOES IT HAVE TO BE CALLED MORE THAN ONCE?I didn''t know it did have to be called more than once. :)> * rake db:test:load - Recreate the test database from the current schema.rb > ==> Q4. WHY DO WE NEED TO LOAD FROM THE SCHEMA RATHER THAN > MIGRATIONS? IS IT TO AVOID ANY DATA BEING LOADED BY MIGRATIONS FOR > THE TEST DATABASE?The main reason, I believe, is for speed. The thinking is that there''s nothing in the test database that needs to be saved, whereas, you might have pseudo-real-world data in your development database that you don''t want to repopulate. Therefore, the test db is created from scratch, but the development (and production) dbs are migrated.> ==> Q5. WHY IS IT RUN MULTIPLE TIMES? >Is that what you''re seeing? I assume you''re running ''rake db:test:prepare --trace''? * rake db:test:purge - Empty the test database> => Q6. WHY IS IT RUN MULTIPLE TIMES? > => Q7. DOES IT DROP TABLES ALSO?I haven''t looked into those tasks, myself. Probably the very best way to answer these questions is to have a look at lib/tasks/databases.rake in your Rails framework directory. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081106/c9fd4bfe/attachment.html>
Greg Hauptmann
2008-Nov-07 00:35 UTC
[rspec-users] anyone able to explain logic behind "rake spec" startup (e.g. db:test:prepare => abort_if_pending_migration => invoke environment => etc etc)
i run "rake spec --trace" On 11/6/08, Greg Hauptmann <greg.hauptmann.ruby at gmail.com> wrote:> anyone able to explain logic behind "rake spec" startup? i.e. the > below steps & why things occur when they do > > Macintosh-2:myequity greg$ rake spec --trace > (in /Users/greg/source/myequity) > ** Invoke spec (first_time) > ** Invoke db:test:prepare (first_time) > ** Invoke db:abort_if_pending_migrations (first_time) > ** Invoke environment (first_time) > ** Execute environment > ** Execute db:abort_if_pending_migrations > ** Execute db:test:prepare > ** Invoke db:test:load (first_time) > ** Invoke db:test:purge (first_time) > ** Invoke environment > ** Execute db:test:purge > ** Execute db:test:load > ** Invoke db:schema:load (first_time) > ** Invoke environment > ** Execute db:schema:load > ** Execute spec > <cut> > > thanks >-- Sent from my mobile device
Mark Wilden
2008-Nov-07 01:12 UTC
[rspec-users] anyone able to explain logic behind "rake spec" startup (e.g. db:test:prepare => abort_if_pending_migration => invoke environment => etc etc)
> i run "rake spec --trace"That''s not running anything twice, I think. "Invoke" is printed when the task is called, then the tasks it depends on are invoked, then the task is executed. The environment task is invoked several times, but it''s only actually executed once. /// On Thu, Nov 6, 2008 at 4:35 PM, Greg Hauptmann < greg.hauptmann.ruby at gmail.com> wrote:> > On 11/6/08, Greg Hauptmann <greg.hauptmann.ruby at gmail.com> wrote: > > anyone able to explain logic behind "rake spec" startup? i.e. the > > below steps & why things occur when they do > > > > Macintosh-2:myequity greg$ rake spec --trace > > (in /Users/greg/source/myequity) > > ** Invoke spec (first_time) > > ** Invoke db:test:prepare (first_time) > > ** Invoke db:abort_if_pending_migrations (first_time) > > ** Invoke environment (first_time) > > ** Execute environment > > ** Execute db:abort_if_pending_migrations > > ** Execute db:test:prepare > > ** Invoke db:test:load (first_time) > > ** Invoke db:test:purge (first_time) > > ** Invoke environment > > ** Execute db:test:purge > > ** Execute db:test:load > > ** Invoke db:schema:load (first_time) > > ** Invoke environment > > ** Execute db:schema:load > > ** Execute spec > > <cut> > > > > thanks > > > > -- > Sent from my mobile device > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081106/df492bf0/attachment-0001.html>