1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
@test_unit @config
Feature:
The formatter for test coverage can be customized
with the SimpleCov.formatter setting. There are two
built-in formatters:
SimpleCov::Formatter::SimpleFormatter is a simple
formatter returning a string of all files with
theirs coverages.
SimpleCov::Formatter::MultiFormatter is a formatter
used to call multiple formatters at once.
Background:
Given I'm working on the project "faked_project"
Scenario: With SimpleFormatter
Given SimpleCov for Test/Unit is configured with:
"""
require 'simplecov'
SimpleCov.formatter = SimpleCov::Formatter::SimpleFormatter
SimpleCov.at_exit do
puts SimpleCov.result.format!
end
SimpleCov.start do
add_group 'Libs', 'lib/faked_project/'
end
"""
When I successfully run `bundle exec rake test`
Then the output should contain "lib/faked_project/meta_magic.rb (coverage: 100.0%)"
Scenario: With MultiFormatter
Given SimpleCov for Test/Unit is configured with:
"""
require 'simplecov'
SimpleCov.formatters = [
SimpleCov::Formatter::SimpleFormatter,
Class.new do
def format(result)
raise "Unable to format"
end
end
]
SimpleCov.at_exit do
puts SimpleCov.result.format!.join
end
SimpleCov.start do
add_group 'Libs', 'lib/faked_project/'
end
"""
When I successfully run `bundle exec rake test`
Then the output should contain "lib/faked_project/meta_magic.rb (coverage: 100.0%)"
And the output should match /Formatter [^\s]* failed with RuntimeError: Unable to format/
Scenario: With multiple formatters
Given SimpleCov for Test/Unit is configured with:
"""
require 'simplecov'
SimpleCov.formatters = [
SimpleCov::Formatter::SimpleFormatter,
Class.new do
def format(result)
raise "Unable to format"
end
end
]
SimpleCov.at_exit do
puts SimpleCov.result.format!.join
end
SimpleCov.start do
add_group 'Libs', 'lib/faked_project/'
end
"""
When I successfully run `bundle exec rake test`
Then the output should contain "lib/faked_project/meta_magic.rb (coverage: 100.0%)"
And the output should match /Formatter [^\s]* failed with RuntimeError: Unable to format/
|