Sha256: 3a0b49b97037a05b058a2cbac24f7e62cca1b863e5f5f60621dd8d793df318c7

Contents?: true

Size: 1.24 KB

Versions: 32

Compression:

Stored size: 1.24 KB

Contents

require_relative '../../test_helper'
require 'rack'
require 'logster/redis_store'
require 'logster/middleware/viewer'

class TestViewer < Minitest::Test

  class BrokenApp
    def call(env)
      [500, {}, ["broken"]]
    end
  end

  def setup
    Logster.store = Logster::RedisStore.new
  end

  def teardown
    Logster.config.subdirectory = nil
    Logster.store = nil
  end

  def viewer
    @viewer ||= begin
                  Logster.config.subdirectory = "/logsie"
                  Logster::Middleware::Viewer.new(nil)
                end
  end

  def test_path_resolution
    assert_nil(viewer.send(:resolve_path, "/logs"))
    assert_nil(viewer.send(:resolve_path, "/admin/logsie"))
    assert_nil(viewer.send(:resolve_path, "/admin/logsie/bla"))
    assert_equal("/",viewer.send(:resolve_path, "/logsie"))
    assert_equal("/",viewer.send(:resolve_path, "/logsie/"))
    assert_equal("/hello/world",viewer.send(:resolve_path, "/logsie/hello/world"))
  end

  def test_assets
    env = {}
    env["PATH_INFO"] = "/logsie/javascript/external/jquery.min.js"
    env["REQUEST_METHOD"] = "GET"

    result,  = viewer.call(env)
    assert_equal(200, result)
  end

  def test_regex_parse
    assert_equal(/hello/i, viewer.send(:parse_regex, '/hello/i'))
  end

end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
logster-1.2.8 test/logster/middleware/test_viewer.rb
logster-1.2.7 test/logster/middleware/test_viewer.rb
logster-1.2.6 test/logster/middleware/test_viewer.rb
logster-1.2.5 test/logster/middleware/test_viewer.rb
logster-1.2.4 test/logster/middleware/test_viewer.rb
logster-1.2.3 test/logster/middleware/test_viewer.rb
logster-1.2.2 test/logster/middleware/test_viewer.rb
logster-1.2.1 test/logster/middleware/test_viewer.rb
logster-1.2.0 test/logster/middleware/test_viewer.rb
logster-1.1.1 test/logster/middleware/test_viewer.rb
logster-1.0.1 test/logster/middleware/test_viewer.rb
logster-1.0.0.3.pre test/logster/middleware/test_viewer.rb
logster-1.0.0.2.pre test/logster/middleware/test_viewer.rb
logster-1.0.0.1.pre test/logster/middleware/test_viewer.rb
logster-1.0.0.0.pre test/logster/middleware/test_viewer.rb
logster-0.9.9 test/logster/middleware/test_viewer.rb
logster-0.8.4.8.pre test/logster/middleware/test_viewer.rb
logster-0.8.4.7.pre test/logster/middleware/test_viewer.rb
logster-0.8.4.6.pre test/logster/middleware/test_viewer.rb
logster-0.8.4.5.pre test/logster/middleware/test_viewer.rb