Methods
I
S
T
Included Modules
Instance Public methods
instrument(*args, &block)
# File activesupport/test/log_subscriber_test.rb, line 40
def instrument(*args, &block)
  ActiveSupport::Notifications.instrument(*args, &block)
end
setup()
# File activesupport/test/log_subscriber_test.rb, line 30
def setup
  super
  @log_subscriber = MyLogSubscriber.new
end
teardown()
# File activesupport/test/log_subscriber_test.rb, line 35
def teardown
  super
  ActiveSupport::LogSubscriber.log_subscribers.clear
end
test_does_not_fail_with_non_namespaced_events()
# File activesupport/test/log_subscriber_test.rb, line 92
def test_does_not_fail_with_non_namespaced_events
  ActiveSupport::LogSubscriber.attach_to :my_log_subscriber, @log_subscriber
  instrument "whatever"
  wait
end
test_does_not_send_the_event_if_it_doesnt_match_the_class()
# File activesupport/test/log_subscriber_test.rb, line 76
def test_does_not_send_the_event_if_it_doesnt_match_the_class
  ActiveSupport::LogSubscriber.attach_to :my_log_subscriber, @log_subscriber
  instrument "unknown_event.my_log_subscriber"
  wait
  # If we get here, it means that NoMethodError was not raised.
end
test_does_not_send_the_event_if_logger_is_nil()
# File activesupport/test/log_subscriber_test.rb, line 83
def test_does_not_send_the_event_if_logger_is_nil
  ActiveSupport::LogSubscriber.logger = nil
  assert_not_called(@log_subscriber, :some_event) do
    ActiveSupport::LogSubscriber.attach_to :my_log_subscriber, @log_subscriber
    instrument "some_event.my_log_subscriber"
    wait
  end
end
test_does_not_set_color_if_colorize_logging_is_set_to_false()
# File activesupport/test/log_subscriber_test.rb, line 57
def test_does_not_set_color_if_colorize_logging_is_set_to_false
  @log_subscriber.bar(nil)
  assert_equal "cool, isn't it?", @logger.logged(:info).last
end
test_event_is_an_active_support_notifications_event()
# File activesupport/test/log_subscriber_test.rb, line 69
def test_event_is_an_active_support_notifications_event
  ActiveSupport::LogSubscriber.attach_to :my_log_subscriber, @log_subscriber
  instrument "some_event.my_log_subscriber"
  wait
  assert_kind_of ActiveSupport::Notifications::Event, @log_subscriber.event
end
test_event_is_sent_to_the_registered_class()
# File activesupport/test/log_subscriber_test.rb, line 62
def test_event_is_sent_to_the_registered_class
  ActiveSupport::LogSubscriber.attach_to :my_log_subscriber, @log_subscriber
  instrument "some_event.my_log_subscriber"
  wait
  assert_equal %w(some_event.my_log_subscriber), @logger.logged(:info)
end
test_flushes_loggers()
# File activesupport/test/log_subscriber_test.rb, line 98
def test_flushes_loggers
  ActiveSupport::LogSubscriber.attach_to :my_log_subscriber, @log_subscriber
  ActiveSupport::LogSubscriber.flush_all!
  assert_equal 1, @logger.flush_count
end
test_flushes_the_same_logger_just_once()
# File activesupport/test/log_subscriber_test.rb, line 104
def test_flushes_the_same_logger_just_once
  ActiveSupport::LogSubscriber.attach_to :my_log_subscriber, @log_subscriber
  ActiveSupport::LogSubscriber.attach_to :another, @log_subscriber
  ActiveSupport::LogSubscriber.flush_all!
  wait
  assert_equal 1, @logger.flush_count
end
test_logging_does_not_die_on_failures()
# File activesupport/test/log_subscriber_test.rb, line 112
def test_logging_does_not_die_on_failures
  ActiveSupport::LogSubscriber.attach_to :my_log_subscriber, @log_subscriber
  instrument "puke.my_log_subscriber"
  instrument "some_event.my_log_subscriber"
  wait

  assert_equal 1, @logger.logged(:info).size
  assert_equal 'some_event.my_log_subscriber', @logger.logged(:info).last

  assert_equal 1, @logger.logged(:error).size
  assert_match 'Could not log "puke.my_log_subscriber" event. RuntimeError: puke', @logger.logged(:error).last
end
test_proxies_method_to_rails_logger()
# File activesupport/test/log_subscriber_test.rb, line 44
def test_proxies_method_to_rails_logger
  @log_subscriber.foo(nil)
  assert_equal %w(debug), @logger.logged(:debug)
  assert_equal %w(info), @logger.logged(:info)
  assert_equal %w(warn), @logger.logged(:warn)
end
test_set_color_for_messages()
# File activesupport/test/log_subscriber_test.rb, line 51
def test_set_color_for_messages
  ActiveSupport::LogSubscriber.colorize_logging = true
  @log_subscriber.bar(nil)
  assert_equal "\e[31mcool\e[0m, \e[1m\e[34misn't it?\e[0m", @logger.logged(:info).last
end