Skip to content
This repository has been archived by the owner on Mar 13, 2020. It is now read-only.

Commit

Permalink
Ticket #5651: Fix code coverage
Browse files Browse the repository at this point in the history
On Check Api test, the classes are reloaded and this was messing up with
the code coverage. Each time the file was reloaded, it reset the coverage.
This patch merges the results.

Found on simplecov-ruby/simplecov#389
  • Loading branch information
danielafeitosa committed May 11, 2017
1 parent 833ddce commit 6a47f98
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/tasks/coverage.rake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ namespace :test do
SimpleCov.start 'rails' do
coverage_dir 'public/coverage'
end
SimpleCov.at_exit do
SimpleCov.result.format!
end
Rake::Task['test'].execute
end
end
9 changes: 9 additions & 0 deletions test/models/check_api_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ def setup
@project_media_without_translation_result = project_media_without_translation_result
end

test "should send token as header" do
token = BRIDGE_CONFIG['check_api_token']
assert_equal token, Check::HTTPAdapter.headers('context')['X-Check-Token']
end

test "should return project slug as string representation" do
assert_equal 'check-api', @check.to_s
end
Expand Down Expand Up @@ -61,6 +66,10 @@ def setup
private

def reload_classes
SimpleCov.result
SimpleCov.start do
command_name "#{command_name}1"
end
Object.send(:remove_const, :Check) if Module.const_defined?(:Check)
load File.join(Rails.root, 'lib', 'check_api_client.rb')
Sources.send(:remove_const, :CheckApi) if Module.const_defined?(:CheckApi)
Expand Down

0 comments on commit 6a47f98

Please sign in to comment.