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!

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to datamapper+unsubscr...@googlegroups.com.
To post to this group, send email to datamapper@googlegroups.com.
Visit this group at http://groups.google.com/group/datamapper?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to