Sha256: 89dfa2dd196a978e76d051b79f6177bad618eb58222c05e3b35c71496b5fab12

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

require 'csv'
require 'rake'
require 'capybara/accessible'

namespace :capybara_accessible do
  desc 'Report total number of integration tests that are accessible/inaccessible'
  task :report_inaccessible_tests do
    directories_to_exclude = ['features/support']
    directories = Dir['features/**'].concat(Dir['spec/features/**']) - directories_to_exclude
    directories.map! { |d| [d.split('/').last, d]}
    directories.sort!

    total_inaccessible_tests = 0
    total_tests = 0
    CSV.open("output_#{DateTime.now.strftime("%Y%m%dT%H%M")}.csv", 'w') do |csv|
      csv<<['Module', 'Test Folder Path', 'Inaccessible Tests', 'Accessible Tests', 'Total Tests']

      directories.each do |key, directory|
        if directory.split('/').first == 'features'
          inaccessible_count = `git grep "@inaccessible" #{directory} | wc -l`
          total_count = `git grep "Scenario" #{directory} | wc -l`
        else
          inaccessible_count = `git grep "inaccessible.*true" #{directory} | wc -l`
          total_count = `git grep "scenario.*do" #{directory} | wc -l`
        end
        total_inaccessible_tests += inaccessible_count.to_i
        total_tests += total_count.to_i

        csv << ["#{key.upcase}",  "#{directory}", inaccessible_count.to_i, (total_count.to_i - inaccessible_count.to_i), total_count.to_i]
      end
      csv << ['TOTALS',  '', total_inaccessible_tests, total_tests - total_inaccessible_tests, total_tests]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capybara-accessible-0.3.0 lib/capybara/accessible/tasks.rb