seedbank icon indicating copy to clipboard operation
seedbank copied to clipboard

RuntimeError: Don't know how to build task 'environment'

Open xtagon opened this issue 6 years ago • 3 comments

Hi,

I have a hook in my Rspec config to run my test seeds with Seedbank before my test suite runs. Worked great until I tried to upgrade Seedbank to 0.5.0, now I get this error:

An error occurred in a `before(:suite)` hook.
Failure/Error: Rake::Task["db:seed:test"].invoke

RuntimeError:
  Don't know how to build task 'environment' (see --tasks)
# ./spec/rails_helper.rb:66:in `block (2 levels) in <top (required)>'
# -e:1:in `<main>'

Here are the relevant lines from my config:

RSpec.configure do |config|
  # ...
  config.before(:suite) {
    Seedbank.load_tasks
    Rake::Task["db:seed:test"].invoke
  }
  # ...

What is the recommended way of accomplishing this? I don't believe I can do Rails.application.load_seed with Seedbank.

It works fine on 0.4.0.

Thanks!

xtagon avatar Jan 09 '19 19:01 xtagon

Sorry I was traveling when you raised this. I’ll have a look and see if I can recreate the error.

james2m avatar Jan 26 '19 11:01 james2m

Found a solution/workaround:

config.before(:suite) {
  Rails.application.load_tasks
  Seedbank.load_tasks
  Rake::Task["db:seed:test"].invoke
}

xtagon avatar Jul 14 '22 00:07 xtagon

@xtagon thanks for posting your workaround, this worked for me as well 👍

rc-iwoodley avatar Jul 14 '22 17:07 rc-iwoodley