Skip to content

Commit

Permalink
add missing coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Mayer committed Dec 31, 2018
1 parent bab091e commit a53ec64
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/coverband/reporters/web.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def call(env)
case request.path_info
when /.*\.(css|js|gif|png)/
@static.call(env)
when %r{\/}
when %r{\/$}
[200, { 'Content-Type' => 'text/html' }, [index]]
else
[404, { 'Content-Type' => 'text/html' }, ['404 error!']]
Expand Down
23 changes: 23 additions & 0 deletions test/unit/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,27 @@ def setup
coverband = Coverband::Collectors::Coverage.instance.reset_instance
assert_equal ['vendor', 'internal:prelude', 'schema.rb'], coverband.instance_variable_get('@ignore_patterns')
end

test 's3 options' do
Coverband::Collectors::Coverage.instance.reset_instance
Coverband.configure do |config|
config.s3_bucket = 'bucket'
config.s3_region = 'region'
config.s3_access_key_id = 'key_id'
config.s3_secret_access_key = 'secret'
end
assert_equal 'bucket', Coverband.configuration.s3_bucket
assert_equal 'region', Coverband.configuration.s3_region
assert_equal 'key_id', Coverband.configuration.s3_access_key_id
assert_equal 'secret', Coverband.configuration.s3_secret_access_key
end

test 'store raises issues' do
Coverband::Collectors::Coverage.instance.reset_instance
assert_raises RuntimeError do
Coverband.configure do |config|
config.store = 'fake'
end
end
end
end
21 changes: 19 additions & 2 deletions test/unit/reports_html_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def setup
@store.clear!
end

test 'generate scov report' do
test 'generate scov html report' do
Coverband.configure do |config|
config.reporter = 'scov'
config.store = @store
Expand All @@ -23,7 +23,24 @@ def setup
@store.send(:save_report, basic_coverage)

html = Coverband::Reporters::HTMLReport.report(@store,
html: true, open_report: false)
html: true,
open_report: false)
assert_match 'Generated by', html
end

test 'generate scov report file' do
Coverband.configure do |config|
config.reporter = 'scov'
config.store = @store
config.s3_bucket = nil
config.ignore = ['notsomething.rb']
end
mock_file_hash
@store.send(:save_report, basic_coverage)

Coverband::Utils::HTMLFormatter.any_instance.expects(:format!).once
html = Coverband::Reporters::HTMLReport.report(@store,
html: false,
open_report: false)
end
end
23 changes: 18 additions & 5 deletions test/unit/reports_web_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,31 @@ 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 Admin', last_response.body
end

test 'renders show content' do
Coverband::Reporters::HTMLReport.expects(:report).returns('content')
test 'renders 404' do
get '/show'
assert last_response.ok?
assert_equal 'content', last_response.body
assert last_response.not_found?
assert_equal '404 error!', last_response.body
end

test 'clears coverband' do
post '/clear'
assert_equal 301, last_response.status
end

test 'collect_coverage' do
post '/collect_coverage'
assert_equal 301, last_response.status
end

test 'reload_files' do
post '/reload_files'
assert_equal 301, last_response.status
end
end
end
Expand Down

0 comments on commit a53ec64

Please sign in to comment.