Re: Datamapper autoupgrade for test db

26 views
Skip to first unread message

draxxxeus

unread,
May 20, 2013, 1:48:51 AM5/20/13
to datam...@googlegroups.com


On Sunday, 19 May 2013 10:31:41 UTC+5:30, Akshay Khole wrote:
How can I run an autoupgrade for my test database to contain my schema before running my specs ? 

Currently I do not see a rake task doing that. 

Am I missing something?

I have done this in my spec file:

RSpec.configure do |config|
  config_file = YAML.load_file('settingsyml')[
'test']
  DataMapper.setup(:default, config_file['db_url'])
  DataMapper.finalize
  DataMapper::Model.raise_on_save_failure = true

  #--------------------------------------------------------------------------------------------#
  # Flush all tables before each test and enter some default values #
  #--------------------------------------------------------------------------------------------#
  config.before(:each) {
    DataMapper.auto_migrate!
    # Seed tables here
  }

And this in my Rakefile:

    require 'rspec/core/rake_task'
    RSpec::Core::RakeTask.new(:spec)

So, whenever i do:

    $ rake spec
 
It automigrates the db and seeds it and executes the specs

You might want to auto_upgrade! instead of auto_migrate!
Reply all
Reply to author
Forward
0 new messages