Sha256: 83706e352eb550b4445bc90907a99e14faa8c884c7a64f6cdd070189bbfa837d

Contents?: true

Size: 1.67 KB

Versions: 3

Compression:

Stored size: 1.67 KB

Contents

module CukeCataloger

  extend Rake::DSL


  # Adds the gem's provided Rake tasks to the namespace from which the method is called
  def self.create_tasks

    desc 'Add unique id tags to tests in the given directory'
    task 'tag_tests', [:directory, :prefix, :row_id, :id_column_name] do |t, args|
      location = args[:directory] || '.'
      prefix = args[:prefix] || '@test_case_'
      tag_rows = args[:row_id].nil? ? true : args[:row_id]
      id_column_name = args[:id_column_name] || 'test_case_id'

      puts "Tagging tests in '#{location}' with tag '#{prefix}'\n"
      puts "Including outline rows\n" if tag_rows

      tagger = CukeCataloger::UniqueTestCaseTagger.new
      tagger.tag_tests(location, prefix, {}, tag_rows, id_column_name)
    end

    desc 'Scan tests in the given directory for id problems'
    task 'validate_tests', [:directory, :prefix, :out_file, :row_id, :id_column_name] do |t, args|
      location = args[:directory] || '.'
      prefix = args[:prefix] || '@test_case_'
      tag_rows = args[:row_id].nil? ? true : args[:row_id]
      id_column_name = args[:id_column_name] || 'test_case_id'

      puts "Validating tests in '#{location}' with tag '#{prefix}'\n"
      puts "Including outline rows\n" if tag_rows

      results = CukeCataloger::UniqueTestCaseTagger.new.validate_test_ids(location, prefix, tag_rows, id_column_name)
      report_text = CukeCataloger::TextReportFormatter.new.format_data(results)

      if args[:out_file]
        puts "Problems found: #{results.count}"
        File.open(args[:out_file], 'w') { |file| file.write(report_text) }
      else
        puts report_text
      end
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cuke_cataloger-1.6.0 lib/cuke_cataloger/rake_tasks.rb
cuke_cataloger-1.5.0 lib/cuke_cataloger/rake_tasks.rb
cuke_cataloger-1.4.1 lib/cuke_cataloger/rake_tasks.rb