Class: GreenPepper::ListOfExample
- Inherits:
-
CollectionExample
- Object
- ExampleWithFixture
- CollectionExample
- GreenPepper::ListOfExample
- Defined in:
- lib/greenpepper/example/collectionexample.rb
Constant Summary
Constants inherited from CollectionExample
CollectionExample::FIRST_DATA_ROW
Constants inherited from ExampleWithFixture
ExampleWithFixture::EXAMPLE_NAME_COLUMN, ExampleWithFixture::EXAMPLE_NAME_ROW, ExampleWithFixture::FIRST_DATA_ROW, ExampleWithFixture::FIXTURE_NAME_COLUMN, ExampleWithFixture::FIXTURE_NAME_ROW, ExampleWithFixture::HEADER_ROW
Instance Attribute Summary
Attributes inherited from CollectionExample
Attributes inherited from ExampleWithFixture
#fixture_arguments, #fixture_name, #headers
Instance Method Summary collapse
- #do_execute_collection(results, example_data, collection_data) ⇒ Object
- #execute_cell(expected_value, received_value, result_compiled) ⇒ Object
Methods inherited from CollectionExample
#add_header, #add_headers, #add_row, #do_execute, #initialize
Methods inherited from ExampleWithFixture
#add_fixture_argument, #execute, #initialize
Constructor Details
This class inherits a constructor from GreenPepper::CollectionExample
Instance Method Details
#do_execute_collection(results, example_data, collection_data) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/greenpepper/example/collectionexample.rb', line 112 def do_execute_collection(results, example_data, collection_data) table_size = [collection_data.size, example_data.size].max table_size.times do |row_index| result_compiled = false @headers_array.each_with_index do |header, column_index| if header == nil results.add row_index + FIRST_DATA_ROW, column_index, NoExampleResult.new else if row_index < example_data.size expected_value = example_data[row_index][column_index] else expected_value = :Surplus end if row_index < collection_data.size received_value = collection_data[row_index][column_index] else received_value = :Missing end result, result_compiled = execute_cell(expected_value, received_value, result_compiled) results.add row_index + FIRST_DATA_ROW, column_index, result end end results.successes += 1 if result_compiled == false end return results end |
#execute_cell(expected_value, received_value, result_compiled) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/greenpepper/example/collectionexample.rb', line 142 def execute_cell(expected_value, received_value, result_compiled) next_result_compiled = true if result_compiled == false if received_value.is_a? Exception result = WriteExceptionExampleResult.new received_value elsif expected_value == :Surplus result = WriteSurplusExampleResult.new received_value elsif received_value == :Missing result = WriteMissingExampleResult.new elsif (expected_value == received_value) next_result_compiled = false result = SuccessExampleResult.new true else result = WriteExpectedExampleResult.new expected_value, received_value end else if received_value.is_a? Exception result = WriteExceptionExampleResult.new received_value, true elsif expected_value == :Surplus result = WriteSurplusExampleResult.new received_value, true elsif received_value == :Missing result = WriteMissingExampleResult.new true elsif (expected_value == received_value) result = SuccessExampleResult.new true else result = WriteExpectedExampleResult.new expected_value, received_value, true end end return result, next_result_compiled end |