Class: GreenPepper::SetupExample
- Inherits:
-
ExampleWithFixture
- Object
- ExampleWithFixture
- GreenPepper::SetupExample
- Defined in:
- lib/greenpepper/example/setupexample.rb
Constant Summary collapse
- FIXTURE_NAME_ROW =
0
- FIXTURE_NAME_COL =
1
- FIRST_DATA_ROW =
2
- HEADER_ROW =
1
Constants inherited from ExampleWithFixture
ExampleWithFixture::EXAMPLE_NAME_COLUMN, ExampleWithFixture::EXAMPLE_NAME_ROW, ExampleWithFixture::FIXTURE_NAME_COLUMN
Instance Attribute Summary collapse
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Attributes inherited from ExampleWithFixture
#fixture_arguments, #fixture_name, #headers
Instance Method Summary collapse
- #add_header(name) ⇒ Object
- #add_row(values_array) ⇒ Object
- #do_execute(results, fixture_class) ⇒ Object
-
#initialize(fixture_name, name_resolver = NameResolver) ⇒ SetupExample
constructor
A new instance of SetupExample.
Methods inherited from ExampleWithFixture
#add_fixture_argument, #execute
Constructor Details
#initialize(fixture_name, name_resolver = NameResolver) ⇒ SetupExample
Returns a new instance of SetupExample.
21 22 23 24 25 |
# File 'lib/greenpepper/example/setupexample.rb', line 21 def initialize(fixture_name, name_resolver = NameResolver) super fixture_name @values = Array.new @name_resolver= name_resolver end |
Instance Attribute Details
#values ⇒ Object (readonly)
Returns the value of attribute values.
15 16 17 |
# File 'lib/greenpepper/example/setupexample.rb', line 15 def values @values end |
Instance Method Details
#add_header(name) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/greenpepper/example/setupexample.rb', line 27 def add_header(name) header = ExampleInputHeader.new(@name_resolver.format_column_name(name), @name_resolver) @headers.push header header end |
#add_row(values_array) ⇒ Object
34 35 36 |
# File 'lib/greenpepper/example/setupexample.rb', line 34 def add_row(values_array) @values.push values_array end |
#do_execute(results, fixture_class) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/greenpepper/example/setupexample.rb', line 38 def do_execute(results, fixture_class) fixture = instantiate_fixture fixture_class if !(fixture.respond_to? "enter_row") ex = ErrorHelper.create_greenpepper_missing_method 'enter_row', fixture_class results.add FIXTURE_NAME_ROW, FIXTURE_NAME_COL, WriteExceptionExampleResult.new(ex) return results end @values.each_index{ |row_index| headers.each_index{ |column_index| header = headers[column_index] string_value = @values[row_index][column_index] value = TypeConverter.instance.auto_convert_string( fixture, header.name, string_value) begin header.execute value, fixture rescue => error result = WriteExceptionExampleResult.new(error) results.add row_index + FIRST_DATA_ROW, column_index, result end } begin result = fixture.enter_row if result result = WriteSucessExampleResult.new true else result = WriteFailExampleResult.new end rescue => error result = WriteExceptionExampleResult.new(error) end results.add row_index + FIRST_DATA_ROW, headers.size, result } results end |