Skip to content

Commit

Permalink
Fix tests for when Rails.logger is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
rmosolgo committed Oct 25, 2023
1 parent f9ff845 commit d56efc2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions spec/graphql/logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,22 @@
describe "Schema.default_logger" do
if defined?(Rails)
it "When Rails is present, returns the Rails logger" do
prev_logger = Rails.logger # might be `nil`
Rails.logger = Object.new
assert_equal Rails.logger, GraphQL::Schema.default_logger
ensure
Rails.logger = prev_logger
end

it "When Rails is present but the logger is nil, it returns a new logger" do
prev_logger = Rails.logger
Rails.logger = nil
refute_equal Rails.logger, GraphQL::Schema.default_logger
assert_instance_of Logger, GraphQL::Schema.default_logger
ensure
Rails.logger = prev_logger
end

else
it "Without Rails, returns a new logger" do
assert_instance_of Logger, GraphQL::Schema.default_logger
Expand Down

0 comments on commit d56efc2

Please sign in to comment.