Class: GreenPepper::FreeTextExample

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fixture_name) ⇒ FreeTextExample

Returns a new instance of FreeTextExample.



16
17
18
19
# File 'lib/greenpepper/example/freetextexample.rb', line 16

def initialize(fixture_name)
  @fixture_name = fixture_name
  @actions = []
end

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions.



14
15
16
# File 'lib/greenpepper/example/freetextexample.rb', line 14

def actions
  @actions
end

#fixture_nameObject (readonly)

Returns the value of attribute fixture_name.



14
15
16
# File 'lib/greenpepper/example/freetextexample.rb', line 14

def fixture_name
  @fixture_name
end

Instance Method Details

#add_action(action) ⇒ Object



21
22
23
# File 'lib/greenpepper/example/freetextexample.rb', line 21

def add_action(action)
  @actions << action
end

#executeObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/greenpepper/example/freetextexample.rb', line 25

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

  if fixture_class.nil?
    results.add_result HeaderError.new(@fixture_name, 
      GreenPepperMissingHeaderError.new)
    return results
  end

  results.add_result HeaderSuccess.new(@fixture_name)

  fixture = fixture_class.new

  @actions.each_with_index{ |action, index|
    begin
      keyword = fixture.greenpepper_map_action action
      results.add_result keyword.get_result
    rescue Exception => e
      results.add_result ActionError.new(e)
    end
  }

  results
end