Class: BarkingIguana::Compound::TestSuite
- Inherits:
-
Object
- Object
- BarkingIguana::Compound::TestSuite
- Includes:
- Benchmark, Logging::Helper
- Defined in:
- lib/barking_iguana/compound/test_suite.rb
Instance Attribute Summary collapse
-
#control_directory ⇒ Object
readonly
Returns the value of attribute control_directory.
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
Class Method Summary collapse
Instance Method Summary collapse
- #debug? ⇒ Boolean
- #define_rake_tasks ⇒ Object
- #environment ⇒ Object
- #environment_file ⇒ Object
- #guess_directory ⇒ Object
-
#initialize(directory = nil, control_directory: nil) ⇒ TestSuite
constructor
A new instance of TestSuite.
- #name ⇒ Object
- #run ⇒ Object
- #tests ⇒ Object
Constructor Details
#initialize(directory = nil, control_directory: nil) ⇒ TestSuite
Returns a new instance of TestSuite.
47 48 49 50 |
# File 'lib/barking_iguana/compound/test_suite.rb', line 47 def initialize(directory = nil, control_directory: nil) self.control_directory = control_directory || guess_directory self.directory = directory || File.("test/compound", control_directory) end |
Instance Attribute Details
#control_directory ⇒ Object
Returns the value of attribute control_directory.
41 42 43 |
# File 'lib/barking_iguana/compound/test_suite.rb', line 41 def control_directory @control_directory end |
#directory ⇒ Object
Returns the value of attribute directory.
44 45 46 |
# File 'lib/barking_iguana/compound/test_suite.rb', line 44 def directory @directory end |
Class Method Details
.define_rake_tasks ⇒ Object
4 5 6 |
# File 'lib/barking_iguana/compound/test_suite.rb', line 4 def self.define_rake_tasks new.define_rake_tasks end |
Instance Method Details
#debug? ⇒ Boolean
37 38 39 |
# File 'lib/barking_iguana/compound/test_suite.rb', line 37 def debug? ENV['DEBUG'].to_s != '' end |
#define_rake_tasks ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/barking_iguana/compound/test_suite.rb', line 8 def define_rake_tasks Rake::Task.define_task name do run end.add_description "Run #{name} suite" tests.each do |test| Rake::Task.define_task "#{name}:#{test.name}" do test.run end.add_description "Run #{test.name} test from #{name} suite" if debug? test.stages.each do |stage| Rake::Task.define_task "#{name}:#{test.name}:#{stage.name}" do stage.run end.add_description "Run #{stage.name} stage of the #{test.name} test from #{name} suite" stage.actions.each do |action| Rake::Task.define_task "#{name}:#{test.name}:#{stage.name}:#{action}" do stage.public_send action end.add_description "Run action #{action} for #{stage.name} stage of the #{test.name} test from #{name} suite" end end Rake::Task.define_task "#{name}:#{test.name}:destroy" do test.teardown end.add_description "Tear down #{test.name} test from #{name} suite" end end end |
#environment ⇒ Object
81 82 83 |
# File 'lib/barking_iguana/compound/test_suite.rb', line 81 def environment @environment ||= Environment.new(environment_file) end |
#environment_file ⇒ Object
77 78 79 |
# File 'lib/barking_iguana/compound/test_suite.rb', line 77 def environment_file File.join directory, 'env' end |
#guess_directory ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/barking_iguana/compound/test_suite.rb', line 52 def guess_directory caller.detect do |trace| path = trace.split(/:/, 2)[0] file = File.basename path break File.dirname path if file == 'Rakefile' end end |
#name ⇒ Object
64 65 66 |
# File 'lib/barking_iguana/compound/test_suite.rb', line 64 def name File.basename directory end |
#run ⇒ Object
71 72 73 74 75 |
# File 'lib/barking_iguana/compound/test_suite.rb', line 71 def run benchmark name do tests.each &:run end end |
#tests ⇒ Object
60 61 62 |
# File 'lib/barking_iguana/compound/test_suite.rb', line 60 def tests test_directories.map { |d| Test.new self, d } end |