Sha256: c664149c52c302db923d1eab49056083809485ec99af8183ca9ab253f48db272

Contents?: true

Size: 1.62 KB

Versions: 2

Compression:

Stored size: 1.62 KB

Contents

# frozen_string_literal: true

require File.expand_path("../../test_helper", File.dirname(__FILE__))
require File.expand_path("../../../lib/coverband/reporters/web", File.dirname(__FILE__))
require "rack/test"

ENV["RACK_ENV"] = "test"

module Coverband
  class WebTest < Minitest::Test
    include Rack::Test::Methods

    def app
      Coverband::Reporters::Web.new
    end

    def teardown
      super
    end

    test "renders index content" do
      get "/"
      assert last_response.ok?
      assert_match "Coverband Home", last_response.body
    end

    test "renders index content for empty path" do
      get ""
      assert last_response.ok?
      assert_match "Coverband Home", last_response.body
    end

    test "renders 404" do
      get "/show"
      assert last_response.not_found?
      assert_equal "404 error!", last_response.body
    end

    test "clears coverband" do
      post "/clear"
      assert_equal 302, last_response.status
    end
  end
end

module Coverband
  class AuthWebTest < Minitest::Test
    include Rack::Test::Methods

    def setup
      super
      @store = Coverband.configuration.store
      Coverband.configure do |config|
        config.password = "test_pass"
      end
    end

    def app
      Coverband::Reporters::Web.new
    end

    def teardown
      super
    end

    test "renders index with basic auth" do
      basic_authorize "anything", "test_pass"
      get "/"
      assert last_response.ok?
      assert_match "Coverband Home", last_response.body
    end

    test "renders 401 auth error when not provided" do
      get "/"
      assert_equal 401, last_response.status
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
coverband-6.1.4 test/coverband/reporters/web_test.rb
coverband-6.1.3 test/coverband/reporters/web_test.rb