diff --git a/github-linguist.gemspec b/github-linguist.gemspec index e680b9f5..3f3a0853 100644 --- a/github-linguist.gemspec +++ b/github-linguist.gemspec @@ -23,5 +23,5 @@ Gem::Specification.new do |s| s.add_development_dependency 'pry' s.add_development_dependency 'rake' s.add_development_dependency 'yajl-ruby' - s.add_development_dependency 'color-proximity' + s.add_development_dependency 'color-proximity', '~> 0.2.1' end diff --git a/test/test_color_threshold.rb b/test/test_color_threshold.rb index 14eec913..f19dd73a 100644 --- a/test/test_color_threshold.rb +++ b/test/test_color_threshold.rb @@ -3,12 +3,18 @@ require_relative "./helper" class TestColorThreshold < Minitest::Test include Linguist + def cut_hash(color) + color[1..-1] + end + def test_color_threshold langs_with_colors = Language.all.reject { |language| language.color.nil? } - cp = ColorProximity.new(10, langs_with_colors.map(&:color)) + cp = ColorProximity.new(0.02, langs_with_colors.map { |lang| cut_hash(lang.color) }) failing_threshold = langs_with_colors.map do |lang| - state = cp.within_threshold?(lang.color[1..-1]) - "- #{lang} (#{lang.color}) is close to #{state.last}" unless state.first + state = cp.past_threshold?(cut_hash(lang.color)) + if !state.first && lang.color != "##{state.last.first}" + "- #{lang} (#{lang.color}) is too close to #{state.last}" + end end.compact message = "The following languages have failing color thresholds. Please modify the hex color.\n#{failing_threshold.join("\n")}"