Sha256: 7b0603462a3db58ae9b825de2ce0f5282b7ae8aedb4c8fa0a0b283f52ffd5e89

Contents?: true

Size: 727 Bytes

Versions: 5

Compression:

Stored size: 727 Bytes

Contents

require 'spec_helper'
require 'active_support/log_subscriber/test_helper'

describe SequelRails::Railties::LogSubscriber do
  include ActiveSupport::LogSubscriber::TestHelper
  def set_logger(logger) # rubocop:disable AccessorMethodName
    SequelRails.configuration.logger = logger
    ActiveSupport::LogSubscriber.logger = logger
  end
  before do
    setup
    described_class.attach_to :sequel
  end
  after { teardown }

  it 'logs queries' do
    User.all
    wait
    expect(@logger.logged(:debug).last).to match(/SELECT \* FROM ("|`)users("|`)/)
  end

  it 'does not log query when logger level is not debug' do
    @logger.level = :info
    User.all
    wait
    expect(@logger.logged(:debug).size).to eq 0
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sequel-rails-0.9.10 spec/lib/sequel_rails/railties/log_subscriber_spec.rb
sequel-rails-0.9.9 spec/lib/sequel_rails/railties/log_subscriber_spec.rb
sequel-rails-0.9.8 spec/lib/sequel_rails/railties/log_subscriber_spec.rb
sequel-rails-0.9.7 spec/lib/sequel_rails/railties/log_subscriber_spec.rb
sequel-rails-0.9.6 spec/lib/sequel_rails/railties/log_subscriber_spec.rb