Class: GreenPepper::ExampleWithFixture

Inherits:
Object
  • Object
show all
Defined in:
lib/greenpepper/example/examplewithfixture.rb

Constant Summary collapse

EXAMPLE_NAME_ROW =
0
EXAMPLE_NAME_COLUMN =
0
FIXTURE_NAME_ROW =
0
FIXTURE_NAME_COLUMN =
1
HEADER_ROW =
1
FIRST_DATA_ROW =
1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fixture_name) ⇒ ExampleWithFixture

Returns a new instance of ExampleWithFixture.



20
21
22
23
24
25
26
27
28
# File 'lib/greenpepper/example/examplewithfixture.rb', line 20

def initialize(fixture_name)
  if fixture_name == nil
    raise GreenPepperMalformedTableError.new(
    'No fixture name provided') 
  end
  @fixture_name = fixture_name
  @fixture_arguments = []
  @headers = []
end

Instance Attribute Details

#fixture_argumentsObject

Returns the value of attribute fixture_arguments.



11
12
13
# File 'lib/greenpepper/example/examplewithfixture.rb', line 11

def fixture_arguments
  @fixture_arguments
end

#fixture_nameObject

Returns the value of attribute fixture_name.



11
12
13
# File 'lib/greenpepper/example/examplewithfixture.rb', line 11

def fixture_name
  @fixture_name
end

#headersObject

Returns the value of attribute headers.



11
12
13
# File 'lib/greenpepper/example/examplewithfixture.rb', line 11

def headers
  @headers
end

Instance Method Details

#add_fixture_argument(value) ⇒ Object



30
31
32
33
# File 'lib/greenpepper/example/examplewithfixture.rb', line 30

def add_fixture_argument(value)
  @fixture_arguments << 
    TypeConverter.instance.convert_string(value)
end

#executeObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/greenpepper/example/examplewithfixture.rb', line 35

def execute
  fixture_class = NameResolver.solve_fixture_name(@fixture_name)
  results = HtmlTableExecutionResults.new

  if fixture_class.nil?
    results.add FIXTURE_NAME_ROW, FIXTURE_NAME_COLUMN, 
      ErrorExampleResult.new
    return results
  end

  begin
    check_headers fixture_class, results, HEADER_ROW
    do_execute results, fixture_class
  rescue GreenPepperError => e
    raise e
  rescue Exception => e
    results.add FIXTURE_NAME_ROW, FIXTURE_NAME_COLUMN, 
      WriteExceptionExampleResult.new(e)
  end
  results
end