Sha256: 3edc98a91ec5ce76825962daec70c023af4c49d83654903ffbe6427946ba1f9f

Contents?: true

Size: 1.27 KB

Versions: 105

Compression:

Stored size: 1.27 KB

Contents

#!/usr/bin/env ruby

# Find all methods which don't have corresponding test method, or all test
# methods without corresponding method. Produces quite a few false positives,
# but useful for a quick check.

source_files = Dir.glob("lib/vedeu/**/*.rb")
test_files   = Dir.glob("test/lib/vedeu/**/*_test.rb")

test_files.each do |test_file|
  source_file = test_file.gsub(/^test\/|_test/, '')
  if File.exist?(source_file)
    source_defs = File.readlines(source_file).select { |line| line[/def /] }.map(&:lstrip).map do |line|
      line.chomp!
      line.gsub!(/^def /, '')
      line.gsub(/\(.*/, '')
    end

    defs = File.readlines(test_file).select { |line| line[/describe /] }.map(&:lstrip).map do |line|
      line.chomp!
      line.gsub!(/^describe /, '')
      line.gsub!(/ do$/, '')
    end
    test_defs = defs.keep_if { |line| line =~ /\'/ }.map { |line| line.gsub!(/\'|#|\./, '') }

    unless (test_defs - source_defs).empty?
      puts "\e[33m#{test_file} \e[31m(test without source)\e[39m\n #{(test_defs - source_defs).inspect}"
    end

    unless (source_defs - test_defs).empty?
      puts "\e[34m#{source_file} \e[31m(source without test)\e[39m\n #{(source_defs - test_defs).inspect}"
    end

    puts

  else
    puts "#{test_file} has no matching source file."

  end
end


Version data entries

105 entries across 105 versions & 1 rubygems

Version Path
vedeu-0.6.26 test/support/coverage.rb
vedeu-0.6.25 test/support/coverage.rb
vedeu-0.6.24 test/support/coverage.rb
vedeu-0.6.23 test/support/coverage.rb
vedeu-0.6.22 test/support/coverage.rb
vedeu-0.6.21 test/support/coverage.rb
vedeu-0.6.20 test/support/coverage.rb
vedeu-0.6.19 test/support/coverage.rb
vedeu-0.6.18 test/support/coverage.rb
vedeu-0.6.17 test/support/coverage.rb
vedeu-0.6.16 test/support/coverage.rb
vedeu-0.6.15 test/support/coverage.rb
vedeu-0.6.14 test/support/coverage.rb
vedeu-0.6.13 test/support/coverage.rb
vedeu-0.6.12 test/support/coverage.rb
vedeu-0.6.11 test/support/coverage.rb
vedeu-0.6.10 test/support/coverage.rb
vedeu-0.6.9 test/support/coverage.rb
vedeu-0.6.8 test/support/coverage.rb
vedeu-0.6.7 test/support/coverage.rb