Project

General

Profile

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

hammer-cli-csv / Rakefile @ 611959a3

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/*.yml`
7
  `rm -rf test/fixtures/vcr_cassettes/extensions/*.yml`
8
  `rm -rf test/fixtures/vcr_cassettes/support/*.yml`
9
  print "Cassettes cleared\n"
10
end
11

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

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

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

    
28
        test_runner = CsvMiniTestRunner.new
29

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

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

    
43

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

    
51
namespace :gettext do
52
  desc "Update pot file"
53
  task :find do
54
    require "hammer_cli_csv/version"
55
    require "hammer_cli_csv/i18n"
56
    require 'gettext/tools'
57

    
58
    domain = HammerCLICsv::I18n::LocaleDomain.new
59
    GetText.update_pofiles(domain.domain_name, domain.translated_files, "#{domain.domain_name} #{HammerCLICsv.version}", :po_root => domain.locale_dir)
60
  end
61
end
62

    
63
desc 'Clears out all cassette files'
64
task :clear_cassettes do
65
  clear_cassettes
66
end
67

    
68
desc 'Runs all tests'
69
task :test do
70
  Rake::Task['test:setup'].invoke
71
  Rake::Task['test:resources'].invoke
72
end
73

    
74
task :default do
75
  Rake::Task['rubocop'].execute
76
  Rake::Task['test'].execute
77
end