Class: GasLoadTester::GroupTest

Inherits:
Object
  • Object
show all
Defined in:
lib/gas_load_tester/group_test.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ GroupTest

Returns a new instance of GroupTest.

Raises:



4
5
6
7
8
9
10
11
12
13
# File 'lib/gas_load_tester/group_test.rb', line 4

def initialize(args)
  raise Error.new('An argument should be an Array') unless args.instance_of?(Array)
  self.tests = args.collect{|test_object|
    if test_object.instance_of?(Test)
      test_object
    else
      Test.new test_object
    end
  }
end

Instance Attribute Details

#testsObject

Returns the value of attribute tests.



3
4
5
# File 'lib/gas_load_tester/group_test.rb', line 3

def tests
  @tests
end

Instance Method Details

#export_file(args = {}) ⇒ Object



28
29
30
31
32
33
# File 'lib/gas_load_tester/group_test.rb', line 28

def export_file(args = {})
  file = args[:file_name] || ''
  chart_builder = GasLoadTester::ChartBuilder.new(file_name: file)
  chart_builder.build_group_body(self)
  chart_builder.save
end

#run(args = {}, &block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gas_load_tester/group_test.rb', line 15

def run(args = {}, &block)
  args[:output] ||= args['output']
  args[:file_name] ||= args['file_name']
  not_run_tests = self.tests.select{|test| !test.is_run? }
  not_run_tests.each_with_index do |test, index|
    print "[#{index+1}/#{not_run_tests.count}] "
    test.run(nil, &block) unless test.is_run?
  end
  if args[:output]
    export_file({file_name: args[:file_name]})
  end
end