Sha256: 68c6fc6043ab12ae1d4ec814abc841549846b0aacded923c115ca3363dcd8449
Contents?: true
Size: 1.52 KB
Versions: 9
Compression:
Stored size: 1.52 KB
Contents
require_relative 'test_helper' require 'active_job' require 'dynflow/active_job/queue_adapter' module Dynflow class SampleJob < ::ActiveJob::Base def perform(msg) puts "This job says #{msg}" end end describe 'running jobs' do before(:all) do world = WorldFactory.create_world ::ActiveJob::QueueAdapters.send(:include, ::Dynflow::ActiveJob::QueueAdapters) ::ActiveJob::Base.queue_adapter = :dynflow dynflow_mock = Minitest::Mock.new dynflow_mock.expect(:world, world) rails_app_mock = Minitest::Mock.new rails_app_mock .expect(:dynflow, dynflow_mock) rails_mock = Minitest::Mock.new rails_mock.expect(:application, rails_app_mock) @original_rails = ::Rails Object.send(:remove_const, 'Rails') Object.const_set('Rails', rails_mock) end after(:all) do Object.send(:remove_const, 'Rails') Object.const_set('Rails', @original_rails) end it 'is able to run the job right away' do out, = capture_subprocess_io do SampleJob.perform_now 'hello' end assert_match(/job says hello/, out) end it 'enqueues the job' do out, = capture_subprocess_io do SampleJob.perform_later 'hello' end assert_match(/Enqueued Dynflow::SampleJob/, out) end it 'schedules job in the future' do out, = capture_subprocess_io do SampleJob.set(:wait => 1.seconds).perform_later 'hello' end assert_match(/Enqueued Dynflow::SampleJob.*at.*UTC/, out) end end end
Version data entries
9 entries across 9 versions & 1 rubygems