Class: AsProject::TestSuite
- Inherits:
-
Object
- Object
- AsProject::TestSuite
- Defined in:
- lib/test_suite_generator.rb
Instance Attribute Summary collapse
-
#directory ⇒ Object
Returns the value of attribute directory.
-
#package ⇒ Object
Returns the value of attribute package.
-
#test_cases ⇒ Object
Returns the value of attribute test_cases.
Instance Method Summary collapse
- #add_test_case(file) ⇒ Object
- #add_test_suite(dir) ⇒ Object
- #file_location ⇒ Object
- #full_suite_name ⇒ Object
-
#initialize(dir, suite_name) ⇒ TestSuite
constructor
A new instance of TestSuite.
- #package_name ⇒ Object
- #serialize(template_content) ⇒ Object
- #to_s ⇒ Object
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
#directory ⇒ Object
Returns the value of attribute directory.
77 78 79 |
# File 'lib/test_suite_generator.rb', line 77 def directory @directory end |
#package ⇒ Object
Returns the value of attribute package.
77 78 79 |
# File 'lib/test_suite_generator.rb', line 77 def package @package end |
#test_cases ⇒ Object
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_location ⇒ Object
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_name ⇒ Object
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_name ⇒ Object
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_s ⇒ Object
124 125 126 |
# File 'lib/test_suite_generator.rb', line 124 def to_s return "Suite for: " + @directory + "\n" end |