Sha256: 165ac97401baea3fd2bfa0f69b26e06d4580c091ace325b6f8c4e9e8a05eff9a

Contents?: true

Size: 1.23 KB

Versions: 26

Compression:

Stored size: 1.23 KB

Contents

# Utilities that are only used in the testing code
require 'stringio'

module OpenID
  module TestUtil
    def assert_log_matches(*regexes)
      begin
        old_logger = Util.logger
        log_output = StringIO.new
        Util.logger = Logger.new(log_output)
        result = yield
      ensure
        Util.logger = old_logger
      end
      log_output.rewind
      log_lines = log_output.readlines
      assert_equal(regexes.length, log_lines.length,
                   [regexes, log_lines].inspect)
      log_lines.zip(regexes) do |line, regex|
        assert_match(regex, line)
      end
      result
    end

    def assert_log_line_count(num_lines)
      begin
        old_logger = Util.logger
        log_output = StringIO.new
        Util.logger = Logger.new(log_output)
        result = yield
      ensure
        Util.logger = old_logger
      end
      log_output.rewind
      log_lines = log_output.readlines
      assert_equal(num_lines, log_lines.length)
      result
    end

    def silence_logging
      begin
        old_logger = Util.logger
        log_output = StringIO.new
        Util.logger = Logger.new(log_output)
        result = yield
      ensure
        Util.logger = old_logger
      end
      result
    end
  end
end

Version data entries

26 entries across 26 versions & 4 rubygems

Version Path
ruby-openid-2.9.2 test/util.rb
ruby-openid-2.9.1 test/util.rb
ruby-openid-2.8.0 test/util.rb
ruby-openid-2.7.0 test/util.rb
ruby-openid-2.6.0 test/util.rb
pelle-ruby-openid-2.1.8 test/util.rb
ruby-openid-2.5.0 test/util.rb
ruby-openid-2.4.0 test/util.rb
ruby-openid-2.3.0 test/util.rb
ruby-openid-2.2.3 test/util.rb
ruby-openid-2.2.2 test/util.rb
ruby-openid-2.2.1 test/util.rb
ruby-openid-2.2.0 test/util.rb
entp-ruby-openid-2.2 test/support/test_util.rb
nov-ruby-openid-2.1.9 test/util.rb
ruby-openid-2.1.8 test/util.rb
pelle-ruby-openid-2.1.9 test/util.rb
ruby-openid-2.1.7 test/util.rb
ruby-openid-2.0.1 test/util.rb
ruby-openid-2.0.2 test/util.rb