Module: Minitest::Flog::Assertions
- Included in:
- Test
- Defined in:
- lib/minitest/flog/assertions.rb
Constant Summary collapse
- DEFAULT_FLOG_OPTIONS =
{ all: true, continue: true }
- DEFAULT_METHOD_OPTIONS =
{ score: 40.0, ratio: 1.0 }
Instance Attribute Summary collapse
-
#dir ⇒ Object
Returns the value of attribute dir.
-
#filtered ⇒ Object
Returns the value of attribute filtered.
-
#threshold ⇒ Object
Returns the value of attribute threshold.
Instance Method Summary collapse
Instance Attribute Details
#dir ⇒ Object
Returns the value of attribute dir.
9 10 11 |
# File 'lib/minitest/flog/assertions.rb', line 9 def dir @dir end |
#filtered ⇒ Object
Returns the value of attribute filtered.
9 10 11 |
# File 'lib/minitest/flog/assertions.rb', line 9 def filtered @filtered end |
#threshold ⇒ Object
Returns the value of attribute threshold.
9 10 11 |
# File 'lib/minitest/flog/assertions.rb', line 9 def threshold @threshold end |
Instance Method Details
#_flog_scores_for_directory(dir) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/minitest/flog/assertions.rb', line 26 def _flog_scores_for_directory(dir) flog = flog_for(dir) scores = {} flog.each_by_score do |method, score, list| scores[method] = score end scores end |
#assert_method_score(dir, options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/minitest/flog/assertions.rb', line 11 def assert_method_score(dir, = {}) = DEFAULT_METHOD_OPTIONS.merge self.dir = dir self.threshold = [:score] scores = _flog_scores_for_directory(dir) self.filtered = scores.select { |method, score| score > [:score] } score_count = scores.count.to_f.round(2) filtered_count = self.filtered.count.to_f.round(2) msg = [:msg] || ([:score], [:ratio], 1.0 - (filtered_count / score_count)) assert (filtered_count / score_count) <= (1.0 - [:ratio]), msg end |