mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-03 06:59:14 +00:00
This will hopefully fix our bild. I believe that the underlying issue is
that the logger's test double gets leaked into other examples, as RSpec
tells when running `spec/jobs/` specs.
```
5) SubscriptionPlacementJob performing the job when unplaced proxy_orders exist processes placeable proxy_orders
Failure/Error: JobLogger.logger.info("Placing Order for Proxy Order #{proxy_order.id}")
#<InstanceDouble(Logger) (anonymous)> was originally created in one example but has leaked into another example and can no longer be used. rspec-mocks' doubles are designed to only last for one example, and you need to create a new one in each example you wish to use it for.
# ./app/jobs/subscription_placement_job.rb:31:in `place_order_for'
```
Read more: https://relishapp.com/rspec/rspec-mocks/v/3-4/docs/basics/scope#doubles-cannot-be-reused-in-another-example
For whatever reason the JobLogger keeps its `.logger` being stubbed
after this spec.
24 lines
678 B
Ruby
24 lines
678 B
Ruby
require 'spec_helper'
|
|
|
|
describe JobLogger do
|
|
describe '.logger' do
|
|
it "returns a Ruby's logger instance" do
|
|
expect(JobLogger.logger).to respond_to(:info)
|
|
end
|
|
|
|
it 'returns custom formatted logger instance' do
|
|
expect(JobLogger.logger.formatter).to be_instance_of(JobLogger::Formatter)
|
|
end
|
|
end
|
|
|
|
describe JobLogger::Formatter do
|
|
describe '#call' do
|
|
it 'outputs timestamps, progname and message' do
|
|
timestamp = DateTime.new(2020,5,6, 22, 36, 0)
|
|
log_line = JobLogger::Formatter.new.call(nil, timestamp, 'progname', 'message')
|
|
expect(log_line).to eq("2020-05-06T22:36:00+0000: message\n")
|
|
end
|
|
end
|
|
end
|
|
end
|