-
-
Notifications
You must be signed in to change notification settings - Fork 388
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
Add specs for Coverage.supported?
#1039
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require_relative '../../spec_helper' | ||
require 'coverage' | ||
|
||
describe "Coverage.supported?" do | ||
ruby_version_is "3.2" do | ||
it "returns true or false if coverage measurement is supported for the given mode" do | ||
[true, false].should.include?(Coverage.supported?(:lines)) | ||
[true, false].should.include?(Coverage.supported?(:branches)) | ||
[true, false].should.include?(Coverage.supported?(:methods)) | ||
[true, false].should.include?(Coverage.supported?(:eval)) | ||
end | ||
|
||
it "returns false for not existing modes" do | ||
Coverage.supported?(:foo).should == false | ||
Coverage.supported?(:bar).should == false | ||
end | ||
|
||
it "raise TypeError if argument is not Symbol" do | ||
-> { | ||
Coverage.supported?("lines") | ||
}.should raise_error(TypeError, "wrong argument type String (expected Symbol)") | ||
|
||
-> { | ||
Coverage.supported?([]) | ||
}.should raise_error(TypeError, "wrong argument type Array (expected Symbol)") | ||
|
||
-> { | ||
Coverage.supported?(1) | ||
}.should raise_error(TypeError, "wrong argument type Integer (expected Symbol)") | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor: It's kind of feature discovering mechanism so it doesn't make sense to require in specs some specific result (true or false). IMHO the only thing that could be checked is that this method:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it converts argument to Symbol? Isn't it raising an error? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TBH I haven't checked. I meant handling of not Symbol arguments in general. |
||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant something like this:
or
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For arbitrary Symbols that are not
lines
,branches
,methods
noreval
it should always return false?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so.