Skip to content

Started adding spec for coverage #217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions library/coverage/fixtures/start_coverage.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
2 + 2
Coverage.start
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the Coverage.start does here? It seems only line 1 is reported?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is to test coverage for the file that calls Coverage.start.

1 + 1
6 changes: 6 additions & 0 deletions library/coverage/peek_result_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'coverage'

describe 'Coverage.peek_result' do
it 'needs to be reviewed for spec completeness'
end
34 changes: 34 additions & 0 deletions library/coverage/result_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'coverage'

describe 'Coverage.result' do
before :all do
@config_file = fixture __FILE__, 'start_coverage.rb'
end

after :each do
$LOADED_FEATURES.delete(@config_file)
end

it 'gives the covered files as a hash with arrays' do
Coverage.start
require @config_file.chomp('.rb')
result = Coverage.result

result.should == { @config_file => [1, 1, 1] }
end

it 'should list coverage for the required file starting coverage' do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there should be a spec mentioning that coverage is only tracked for load/require after a Coverage.start since it seems this spec relies on that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And maybe one about the fact that Coverage.result disable tracking but that seems difficult since there is no Coverage.enabled?.

require @config_file.chomp('.rb')
result = Coverage.result

result.should == { @config_file => [] }
end

it 'should list coverage for the loaded file starting coverage' do
load @config_file
result = Coverage.result

result.should == { @config_file => [] }
end
end
6 changes: 6 additions & 0 deletions library/coverage/start_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'coverage'

describe 'Coverage.start' do
it 'needs to be reviewed for spec completeness'
end