Project

General

Profile

Download (2.09 KB) Statistics
| Branch: | Tag: | Revision:

hammer-cli-csv / Rakefile @ master

1
#!/usr/bin/env rake
2
require 'bundler/gem_tasks'
3
require 'rake/testtask'
4

    
5
def clear_cassettes
6
  `rm -rf test/fixtures/vcr_cassettes/setup/*.yml`
7
  `rm -rf test/fixtures/vcr_cassettes/resources/*.yml`
8
  print "Cassettes cleared\n"
9
end
10

    
11
namespace :test do
12
  %w(setup resources).each do |task_name|
13
    desc "Runs the #{task_name} tests"
14
    task task_name do
15
      options = {}
16

    
17
      options[:mode]      = ENV['mode'] || 'none'
18
      options[:test_name] = ENV['test']
19
      options[:auth_type] = ENV['auth_type']
20
      options[:logging]   = ENV['logging']
21

    
22
      if !%w(new_episodes all none once).include?(options[:mode])
23
        puts 'Invalid test mode'
24
      else
25
        require './test/test_runner'
26

    
27
        test_runner = CsvMiniTestRunner.new
28

    
29
        if options[:test_name]
30
          puts "Running tests for: #{options[:test_name]}"
31
        else
32
          puts "Running tests for: #{task_name}"
33
        end
34

    
35
        clear_cassettes if options[:mode] == 'all' && options[:test_name].nil? && ENV['record'] != 'false'
36
        test_runner.run_tests(task_name, options)
37
      end
38
    end
39
  end
40
end
41

    
42

    
43
begin
44
  require 'rubocop/rake_task'
45
  RuboCop::RakeTask.new
46
rescue
47
  puts "Rubocop not loaded"
48
end
49

    
50
namespace :gettext do
51
  desc "Update pot file"
52

    
53
  task :setup do
54
    require "hammer_cli_csv/version"
55
    require "hammer_cli_csv/i18n"
56
    require 'gettext/tools/task'
57

    
58
    domain = HammerCLICsv::I18n::LocaleDomain.new
59
    GetText::Tools::Task.define do |task|
60
      task.package_name = domain.domain_name
61
      task.package_version = HammerCLICsv.version.to_s
62
      task.domain = domain.domain_name
63
      task.mo_base_directory = domain.locale_dir
64
      task.po_base_directory = domain.locale_dir
65
      task.files = domain.translated_files
66
    end
67
  end
68

    
69
  desc "Update pot file"
70
  task :find => [:setup] do
71
    Rake::Task["gettext:po:update"].invoke
72
  end
73
end
74

    
75
desc 'Clears out all cassette files'
76
task :clear_cassettes do
77
  clear_cassettes
78
end
79

    
80
desc 'Runs all tests'
81
task :test do
82
  Rake::Task['test:setup'].invoke
83
  Rake::Task['test:resources'].invoke
84
end
85

    
86
task :default do
87
  Rake::Task['rubocop'].execute
88
  Rake::Task['test'].execute
89
end