From 1eb110ac7c11a04be84233e7058746a1de240be5 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 25 Jul 2018 19:35:18 +0200 Subject: [PATCH 1/2] specs: fix random seed being always the same when using Spring --- spec/spec_helper.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b85a13621..4014d9ddd 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -118,6 +118,9 @@ RSpec.configure do |config| config.filter_run :focus => true config.order = 'random' + # Fix the seed not changing between runs when using Spring + # See https://github.com/rails/spring/issues/113 + config.seed = srand % 0xFFFF unless ARGV.any? { |arg| arg =~ /seed/ || arg =~ /rand:/ } config.include Devise::Test::ControllerHelpers, type: :controller config.include Devise::Test::ControllerHelpers, type: :view From 56e3a56badbd147e87bb10d7a7f61f8581462000 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 25 Jul 2018 19:35:27 +0200 Subject: [PATCH 2/2] specs: fix application_job_spec --- spec/jobs/application_job_spec.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/spec/jobs/application_job_spec.rb b/spec/jobs/application_job_spec.rb index 61d9243f9..053156f92 100644 --- a/spec/jobs/application_job_spec.rb +++ b/spec/jobs/application_job_spec.rb @@ -1,12 +1,16 @@ require 'rails_helper' include ActiveJob::TestHelper -RSpec.describe ApplicationJob, type: :job, skip: true do +RSpec.describe ApplicationJob, type: :job do describe 'perform' do - it do - expect(Rails.logger).to receive(:info).with(/.+started at.+/) - expect(Rails.logger).to receive(:info).with(/.+ended at.+/) + before do + allow(Rails.logger).to receive(:info) + end + + it 'logs start time and end time' do perform_enqueued_jobs { ChildJob.perform_later } + expect(Rails.logger).to have_received(:info).with(/started at/).once + expect(Rails.logger).to have_received(:info).with(/ended at/).once end end