Merge pull request #2306 from betagouv/improve-tests

Améliorations sur les tests
This commit is contained in:
Pierre de La Morinerie 2018-07-30 11:17:00 +02:00 committed by GitHub
commit 5cc59bc5e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View file

@ -1,12 +1,16 @@
require 'rails_helper' require 'rails_helper'
include ActiveJob::TestHelper include ActiveJob::TestHelper
RSpec.describe ApplicationJob, type: :job, skip: true do RSpec.describe ApplicationJob, type: :job do
describe 'perform' do describe 'perform' do
it do before do
expect(Rails.logger).to receive(:info).with(/.+started at.+/) allow(Rails.logger).to receive(:info)
expect(Rails.logger).to receive(:info).with(/.+ended at.+/) end
it 'logs start time and end time' do
perform_enqueued_jobs { ChildJob.perform_later } 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
end end

View file

@ -118,6 +118,9 @@ RSpec.configure do |config|
config.filter_run :focus => true config.filter_run :focus => true
config.order = 'random' 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: :controller
config.include Devise::Test::ControllerHelpers, type: :view config.include Devise::Test::ControllerHelpers, type: :view