Skip to content

Conditionally permit the console display of file covered >= threshold #36

Merged
merged 3 commits into from Aug 9, 2014

2 participants

@TiteiKo
TiteiKo commented Jul 10, 2014

Why ?

Two reasons :

  • First time I used coco, I thought that the issue #35 was real
  • For some people (me included), seing only the wrong is kind of depressing...
  • It's easier to evaluate the overall coverage when what's greatly covered is displayed

So I added a small option to display in green files whose coverage is greater or equal to the threshold

@TiteiKo TiteiKo commented on an outdated diff Jul 10, 2014
lib/coco/formatter/console_formatter.rb
@@ -33,6 +33,8 @@ def initialize(covered, uncovered)
text = ColoredString.new "#{percentage}% #{filename}"
if percentage <= 50
text.red
+ elsif percentage == 100
@TiteiKo
TiteiKo added a note Jul 10, 2014

this should be threashold, fix comming up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@lkdjiin
Owner
lkdjiin commented Jul 10, 2014

Great! I will review this PR ASAP ;)
Thank you.

@lkdjiin lkdjiin commented on the diff Aug 8, 2014
lib/coco.rb
@@ -26,7 +26,7 @@ module Coco
sources = Coco::SourceLister.new(config).list
uncovered = Coco::UncoveredLister.new(sources, result.all_from_domain).list
- cf = Coco::ConsoleFormatter.new(covered, uncovered)
+ cf = Coco::ConsoleFormatter.new(covered, uncovered, config[:threshold])
@lkdjiin
Owner
lkdjiin added a note Aug 8, 2014

ok, mea culpa, I would say console_formatter, or maybe console, not cf! WTF, why did I named this variable cf? Sorry ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@lkdjiin lkdjiin commented on the diff Aug 8, 2014
lib/coco/cover/coverage_result.rb
@@ -13,9 +13,9 @@ class CoverageResult
# Returns a Hash coverage for sources that are not sufficiently
# covered. More technically, the sources that live in the root
# project folder and for which the coverage percentage is under the
- # threshold.
@lkdjiin
Owner
lkdjiin added a note Aug 8, 2014

Thank you to remove all those spaces ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@lkdjiin lkdjiin commented on the diff Aug 8, 2014
lib/coco/formatter/console_formatter.rb
@@ -23,8 +23,8 @@ def link
# covered - Hash
# uncovered - Array
- def initialize(covered, uncovered)
@lkdjiin
Owner
lkdjiin added a note Aug 8, 2014

I'll document the threshold argument…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@lkdjiin lkdjiin commented on the diff Aug 8, 2014
spec/formatters_spec.rb
result = formatter.format
result.should == "\e[31m0% a\e[0m\n" +
"\e[31m0% b\e[0m\n" +
"\e[33m80% the/filename/80\e[0m\n" +
"\e[33m90% the/filename/90\e[0m\n" +
- "\e[33m100% the/filename/100\e[0m"
+ "\e[32m100% the/filename/100\e[0m"
+ end
+
+ it "should put in green when >= threshold" do
+ formatter = ConsoleFormatter.new(COVERAGE_100_90_80, ['a', 'b'], 90)
@lkdjiin
Owner
lkdjiin added a note Aug 8, 2014

Yes! I'm happy to see a test with your new feature!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@lkdjiin
Owner
lkdjiin commented Aug 8, 2014

👍
I really like it, thanks again!
I think I'll merge it this week-end, and may be it's the time for a new release…
Do you want to update the readme with your new feature? Else I'll do it ;)

@lkdjiin lkdjiin merged commit ab5ec3f into lkdjiin:development Aug 9, 2014

1 check passed

Details continuous-integration/travis-ci The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.