Class: AsProject::TestSuite

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir, suite_name) ⇒ TestSuite

Returns a new instance of TestSuite.



79
80
81
82
83
# File 'lib/test_suite_generator.rb', line 79

def initialize(dir, suite_name)
  @test_cases = Array.new
  @directory = dir
  @suite_name = suite_name
end

Instance Attribute Details

#directoryObject

Returns the value of attribute directory.



77
78
79
# File 'lib/test_suite_generator.rb', line 77

def directory
  @directory
end

#packageObject

Returns the value of attribute package.



77
78
79
# File 'lib/test_suite_generator.rb', line 77

def package
  @package
end

#test_casesObject

Returns the value of attribute test_cases.



77
78
79
# File 'lib/test_suite_generator.rb', line 77

def test_cases
  @test_cases
end

Instance Method Details

#add_test_case(file) ⇒ Object



85
86
87
88
89
# File 'lib/test_suite_generator.rb', line 85

def add_test_case(file)
  file = file.split('.')[0]
  test_case = file.split(File::SEPARATOR).join('.')
  @test_cases.push(test_case)
end

#add_test_suite(dir) ⇒ Object



91
92
93
94
# File 'lib/test_suite_generator.rb', line 91

def add_test_suite(dir)
  test_case = File.join(dir, @suite_name)
  add_test_case(test_case)
end

#file_locationObject



107
108
109
110
111
112
113
# File 'lib/test_suite_generator.rb', line 107

def file_location
  if(@directory.length > 0)
    return File.join(@directory, @suite_name)
  else
    return @suite_name
  end
end

#full_suite_nameObject



100
101
102
103
104
105
# File 'lib/test_suite_generator.rb', line 100

def full_suite_name
  name = @suite_name.split('.')[0]
  parts = @directory.split(File::SEPARATOR)
  parts << name
  return parts.join('.')
end

#package_nameObject



96
97
98
# File 'lib/test_suite_generator.rb', line 96

def package_name
  @directory.split(File::SEPARATOR).join('.')
end

#serialize(template_content) ⇒ Object



115
116
117
118
119
120
121
122
# File 'lib/test_suite_generator.rb', line 115

def serialize(template_content)
  @test_cases.sort!
  
  parsed = ERB.new(template_content).result(binding)
  file = File.open(file_location, 'w') do |f|
    f.write(parsed)
  end
end

#to_sObject



124
125
126
# File 'lib/test_suite_generator.rb', line 124

def to_s
  return "Suite for: " + @directory + "\n"
end