Sha256: 2d69e2233685bc86917e72ff575ef80fbcfedd55070685be56164fe158f147a5

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

require File.expand_path('../test_helper', File.dirname(__FILE__))
require 'aws-sdk'
require File.expand_path('../../lib/coverband/reporters/web', File.dirname(__FILE__))
require 'rack/test'

ENV['RACK_ENV'] = 'test'

if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.2.0')
  module Coverband
    class S3WebTest < Test::Unit::TestCase
      include Rack::Test::Methods

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

      def teardown
        Coverband.configuration.s3_bucket = nil
      end

      # TODO add tests for all endpoints
      test 'renders index content' do
        get '/'
        assert last_response.ok?
        assert_match 'Coverband Web Admin Index', last_response.body
      end

      test 'renders show content' do
        Coverband.configuration.s3_bucket = 'coverage-bucket'
        s3 = mock('s3')
        Aws::S3::Client.expects(:new).returns(s3)
        s3.expects(:get_object).with(bucket: 'coverage-bucket', key: 'coverband/index.html').returns mock('response', body: mock('body', read: 'content'))
        get '/show'
        assert last_response.ok?
        assert_equal 'content', last_response.body
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
coverband-3.0.0 test/unit/reports_web_test.rb
coverband-3.0.0.alpha2 test/unit/reports_web_test.rb
coverband-3.0.0.alpha test/unit/reports_web_test.rb