mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Move spec/rubyspec to spec/ruby for consistency
* Other ruby implementations use the spec/ruby directory. [Misc #13792] [ruby-core:82287] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
75bfc6440d
commit
1d15d5f080
4370 changed files with 0 additions and 0 deletions
78
spec/ruby/library/coverage/result_spec.rb
Normal file
78
spec/ruby/library/coverage/result_spec.rb
Normal file
|
@ -0,0 +1,78 @@
|
|||
require File.expand_path('../../../spec_helper', __FILE__)
|
||||
require fixture __FILE__, 'spec_helper'
|
||||
require 'coverage'
|
||||
|
||||
describe 'Coverage.result' do
|
||||
before :all do
|
||||
@class_file = fixture __FILE__, 'some_class.rb'
|
||||
@config_file = fixture __FILE__, 'start_coverage.rb'
|
||||
end
|
||||
|
||||
after :each do
|
||||
$LOADED_FEATURES.delete(@class_file)
|
||||
$LOADED_FEATURES.delete(@config_file)
|
||||
end
|
||||
|
||||
it 'gives the covered files as a hash with arrays of count or nil' do
|
||||
Coverage.start
|
||||
require @class_file.chomp('.rb')
|
||||
result = CoverageSpecs.filtered_result
|
||||
|
||||
result.should == {
|
||||
@class_file => [
|
||||
nil, nil, 1, nil, nil, 1, nil, nil, 0, nil, nil, nil, nil, nil, nil, nil
|
||||
]
|
||||
}
|
||||
end
|
||||
|
||||
it 'no requires/loads should give empty hash' do
|
||||
Coverage.start
|
||||
result = CoverageSpecs.filtered_result
|
||||
|
||||
result.should == {}
|
||||
end
|
||||
|
||||
it 'second call should give exception' do
|
||||
Coverage.start
|
||||
require @class_file.chomp('.rb')
|
||||
Coverage.result
|
||||
-> { Coverage.result }
|
||||
.should raise_error(RuntimeError, 'coverage measurement is not enabled')
|
||||
end
|
||||
|
||||
it 'second run should give same result' do
|
||||
Coverage.start
|
||||
load @class_file
|
||||
result1 = CoverageSpecs.filtered_result
|
||||
|
||||
Coverage.start
|
||||
load @class_file
|
||||
result2 = CoverageSpecs.filtered_result
|
||||
|
||||
result2.should == result1
|
||||
end
|
||||
|
||||
it 'second run without load/require should give empty hash' do
|
||||
Coverage.start
|
||||
require @class_file.chomp('.rb')
|
||||
Coverage.result
|
||||
|
||||
Coverage.start
|
||||
result = CoverageSpecs.filtered_result
|
||||
|
||||
result.should == {}
|
||||
end
|
||||
|
||||
it 'second Coverage.start does nothing' do
|
||||
Coverage.start
|
||||
require @config_file.chomp('.rb')
|
||||
result = CoverageSpecs.filtered_result
|
||||
|
||||
result.should == { @config_file => [1, 1, 1] }
|
||||
end
|
||||
|
||||
it 'does not include the file starting coverage since it is not tracked' do
|
||||
require @config_file.chomp('.rb')
|
||||
CoverageSpecs.filtered_result.should_not include(@config_file)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue