Sha256: 58988f42d93e897fdb7a7a91af4919a25b9f2fac8488c860aaeb92c6bbfee60e

Contents?: true

Size: 876 Bytes

Versions: 82

Compression:

Stored size: 876 Bytes

Contents

require 'abstract_unit'

class LoggingController < ActionController::Base
  def show
    render :nothing => true
  end
end

class LoggingTest < ActionController::TestCase
  tests LoggingController

  class MockLogger
    attr_reader :logged
    
    def method_missing(method, *args)
      @logged ||= []
      @logged << args.first
    end
  end

  setup :set_logger

  def test_logging_without_parameters
    get :show
    assert_equal 2, logs.size
    assert_nil logs.detect {|l| l =~ /Parameters/ }
  end

  def test_logging_with_parameters
    get :show, :id => 10
    assert_equal 3, logs.size

    params = logs.detect {|l| l =~ /Parameters/ }
    assert_equal 'Parameters: {"id"=>"10"}', params
  end
  
  private

  def set_logger
    @controller.logger = MockLogger.new
  end
  
  def logs
    @logs ||= @controller.logger.logged.compact.map {|l| l.strip}
  end
end

Version data entries

82 entries across 79 versions & 18 rubygems

Version Path
elkinsware-erubis_rails_helper-0.6.0 test/controller/logging_test.rb
elkinsware-erubis_rails_helper-0.6.1 test/controller/logging_test.rb
elkinsware-erubis_rails_helper-0.9.0 test/controller/logging_test.rb
elkinsware-erubis_rails_helper-0.9.1 test/controller/logging_test.rb
elkinsware-erubis_rails_helper-0.9.5 test/controller/logging_test.rb
ghazel-erubis_rails_helper-0.9.5 test/controller/logging_test.rb
actionpack-2.3.18 test/controller/logging_test.rb
actionpack_csi-2.3.5.p8 test/controller/logging_test.rb
actionpack-2.3.17-rack-upgrade-2.3.17 test/controller/logging_test.rb
actionpack-2.3.17 test/controller/logging_test.rb
actionpack_csi-2.3.5.p7 test/controller/logging_test.rb
actionpack_csi-2.3.5.p6 test/controller/logging_test.rb
actionpack-2.3.16 test/controller/logging_test.rb
actionpack-rack-upgrade-2-2.3.16 test/controller/logging_test.rb
actionpack-rack-upgrade-2-2.3.15 test/controller/logging_test.rb
actionpack-2.3.15 test/controller/logging_test.rb
actionpack-rack-upgrade-2.3.16 test/controller/logging_test.rb
actionpack-rack-upgrade-2.3.15 test/controller/logging_test.rb
actionpack-rack-upgrade-2.3.14 test/controller/logging_test.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/actionpack-2.3.14/test/controller/logging_test.rb