Skip to content

Instantly share code, notes, and snippets.

@cupnoodle
Created May 12, 2018 15:55
Show Gist options
  • Save cupnoodle/8e7df9eb6e2ebdee82d321f45c90d83c to your computer and use it in GitHub Desktop.
Save cupnoodle/8e7df9eb6e2ebdee82d321f45c90d83c to your computer and use it in GitHub Desktop.
Run rake task in rspec test
require 'rake'
# make sure to set correct relative path
load File.expand_path("../../../../lib/tasks/once.rake", __FILE__)
describe 'some name' do
before(:all) do
# because rake task accepts different environment
Rake::Task.define_task(:environment)
#replace 'once:create_tags' with your own rake task
Rake::Task['once:create_tags'].invoke
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment