require 'rake' class FakeRake include Rake::DSL def execute old_rake = Rake.application rake = Rake::Application.new Rake.application = rake task :environment yield(rake) ensure Rake.application = old_rake end end When /^the daily Saucy jobs are processed$/ do FakeRake.new.execute do |rake| Saucy::Engine.load_tasks rake['saucy:daily'].invoke end end