Skip to content

Instantly share code, notes, and snippets.

@sergio-fry
Last active June 5, 2020 12:02
Show Gist options
  • Save sergio-fry/6e06d88907d00957fa420b124eb1c1d3 to your computer and use it in GitHub Desktop.
Save sergio-fry/6e06d88907d00957fa420b124eb1c1d3 to your computer and use it in GitHub Desktop.
RSpec rake support module
APP_RAKEFILE = Rails.root.join('Rakefile')
module Support
module RakeHelpers
extend ActiveSupport::Concern
def rake(task)
Rake::Task[task].reenable
Rake.application.invoke_task(task)
end
included do
RSpec.configure do |config|
config.before type: :rake do
require 'rake'
load 'rails/tasks/engine.rake'
end
end
end
end
end
RSpec.describe 'My task', type: :rake do
it 'works' do
rake 'app:my:task'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment