1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activeresource/test/cases/log_subscriber_test.rb

33 lines
905 B
Ruby
Raw Normal View History

2010-01-13 16:59:27 -05:00
require "abstract_unit"
require "fixtures/person"
require "active_support/log_subscriber/test_helper"
require "active_resource/log_subscriber"
2010-02-08 15:30:59 -05:00
require "active_support/core_ext/hash/conversions"
2010-01-13 16:59:27 -05:00
class LogSubscriberTest < ActiveSupport::TestCase
include ActiveSupport::LogSubscriber::TestHelper
2010-01-13 16:59:27 -05:00
def setup
2010-03-03 01:56:34 -05:00
super
@matz = { :person => { :id => 1, :name => 'Matz' } }.to_json
2010-01-13 16:59:27 -05:00
ActiveResource::HttpMock.respond_to do |mock|
mock.get "/people/1.json", {}, @matz
2010-01-13 16:59:27 -05:00
end
ActiveResource::LogSubscriber.attach_to :active_resource
2010-01-13 16:59:27 -05:00
end
def set_logger(logger)
ActiveResource::Base.logger = logger
end
def test_request_notification
matz = Person.find(1)
wait
assert_equal 2, @logger.logged(:info).size
assert_equal "GET http://37s.sunrise.i:3000/people/1.json", @logger.logged(:info)[0]
assert_match(/\-\-\> 200 200 33/, @logger.logged(:info)[1])
2010-01-13 16:59:27 -05:00
end
end