Created
December 8, 2016 06:00
-
-
Save 8parth/42fae37b50ce11d78855edc856a962a3 to your computer and use it in GitHub Desktop.
Ignoring swagger-docs lines by treating them as comments for simplecov gem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SimpleCov | |
class SourceFile | |
class Line | |
def reinitialize_line(coverage) | |
raise ArgumentError, "Only Integer and nil accepted for coverage" unless coverage.is_a?(Integer) || coverage.nil? | |
@coverage = coverage | |
@skipped = false | |
end | |
end | |
end | |
end | |
SimpleCov.start 'rails' do | |
add_filter do |source_file| | |
if source_file.filename.include?("api/v1") | |
swagger_lines = [] | |
source_file.lines.each do |line| | |
if line.src.include? "param :" or line.src.include? "swagger_controller" or line.src.include? "swagger_api" or line.src.include? "ApplicationController::add_common_params(api)" or line.src.include? "summary" or line.src.include? "notes" or line.src.include? "response" | |
swagger_lines << line | |
end | |
end | |
swagger_lines.each do |line| | |
line.reinitialize_line(nil) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment