Class: Fog::Rake::TestTask

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/tasks/test_task.rb

Instance Method Summary collapse

Constructor Details

#initializeTestTask

Returns a new instance of TestTask.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/tasks/test_task.rb', line 8

def initialize
  desc "Run the mocked tests"
  task :test do
    Rake::Task[:mock_tests].invoke
  end

  task :mock_tests do
    tests(true)
  end

  task :real_tests do
    tests(false)
  end
end

Instance Method Details

#tests(mocked) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/tasks/test_task.rb', line 23

def tests(mocked)
  Formatador.display_line
  start = Time.now.to_i
  threads = []
  Thread.main[:results] = []
  Fog.providers.each do |key, value|
    threads << Thread.new do
      Thread.main[:results] << {
        :provider => value,
        :success  => sh("export FOG_MOCK=#{mocked} && bundle exec shindont +#{key}")
      }
    end
  end
  threads.each do |thread|
    thread.join
  end
  Formatador.display_table(Thread.main[:results].sort {|x,y| x[:provider] <=> y[:provider]})
  Formatador.display_line("[bold]FOG_MOCK=#{mocked}[/] tests completed in [bold]#{Time.now.to_i - start}[/] seconds")
  Formatador.display_line
end