Project

General

Profile

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

hammer-cli-csv / Rakefile @ b50ceaa2

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
# Rake::TestTask.new do |t|
13
#   t.libs << "lib"
14
#   t.test_files = Dir['test/setup_test.rb'] + Dir.glob('test/**/*_test.rb')
15
#   t.verbose = true
16
# end
17

    
18
namespace :test do
19
  [:resources].each do |task_name|
20
    desc "Runs the #{task_name} tests"
21
    task task_name do
22
      options = {}
23

    
24
      options[:mode]      = ENV['mode'] || 'none'
25
      options[:test_name] = ENV['test']
26
      options[:auth_type] = ENV['auth_type']
27
      options[:logging]   = ENV['logging']
28

    
29
      if !%w(new_episodes all none once).include?(options[:mode])
30
        puts 'Invalid test mode'
31
      else
32
        require './test/test_runner'
33

    
34
        test_runner = CsvMiniTestRunner.new
35

    
36
        if options[:test_name]
37
          puts "Running tests for: #{options[:test_name]}"
38
        else
39
          puts "Running tests for: #{task_name}"
40
        end
41

    
42
        clear_cassettes if options[:mode] == 'all' && options[:test_name].nil? && ENV['record'] != 'false'
43
        test_runner.run_tests(task_name, options)
44
      end
45
    end
46
  end
47
end
48

    
49

    
50
begin
51
  require 'rubocop/rake_task'
52
  RuboCop::RakeTask.new
53
rescue
54
  puts "Rubocop not loaded"
55
end
56

    
57
namespace :gettext do
58
  desc "Update pot file"
59
  task :find do
60
    require "hammer_cli_csv/version"
61
    require "hammer_cli_csv/i18n"
62
    require 'gettext/tools'
63

    
64
    domain = HammerCLICsv::I18n::LocaleDomain.new
65
    GetText.update_pofiles(domain.domain_name, domain.translated_files, "#{domain.domain_name} #{HammerCLICsv.version}", :po_root => domain.locale_dir)
66
  end
67
end
68

    
69
desc 'Clears out all cassette files'
70
task :clear_cassettes do
71
  clear_cassettes
72
end
73

    
74
desc 'Runs all tests'
75
task :test do
76
  Rake::Task['test:resources'].invoke
77
end
78

    
79
task :default do
80
  Rake::Task['rubocop'].execute
81
  Rake::Task['test'].execute
82
end