Class: Fit::ActionFixture

Inherits:
Fixture
  • Object
show all
Defined in:
lib/fit/action_fixture.rb

Direct Known Subclasses

TimedActionFixture

Constant Summary collapse

@@actor =
nil

Constants inherited from Fixture

Fixture::GRAY, Fixture::GREEN, Fixture::RED, Fixture::YELLOW

Instance Attribute Summary

Attributes inherited from Fixture

#args, #counts, #listener, #summary

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Fixture

camel, #do_cell, #do_row, #do_rows, #do_table, #do_tables, #error, escape, #exception, #find_class, #fixture_name, #get_args_for_table, #get_linked_fixture_with_args, gray, #ignore, #info, #initialize, #interpret_following_tables, #interpret_tables, label, metadata, #parse, #right, #total_errors, #totals, #wrong

Constructor Details

This class inherits a constructor from Fit::Fixture

Class Method Details

.actorObject



15
# File 'lib/fit/action_fixture.rb', line 15

def ActionFixture.actor; @@actor; end

.actor=(value) ⇒ Object



16
17
18
# File 'lib/fit/action_fixture.rb', line 16

def ActionFixture.actor= value
  @@actor = value
end

Instance Method Details

#checkObject



56
57
58
59
60
61
# File 'lib/fit/action_fixture.rb', line 56

def check
  method_name = Fixture.camel @cells.more.text
  adapter = TypeAdapter.for(@@actor, method_name, false)
  adapter.type = @@actor.class.[method_name]
  super(@cells.more.more, adapter)
end

#do_cells(cells) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/fit/action_fixture.rb', line 20

def do_cells cells
  @cells = cells
  begin
    send(cells.text)
  rescue Exception => e
    exception cells, e
  end
end

#enterObject

ActionFixture.enter could be called with regular methods featuring a single argument, or on setters methods of the form ‘name=’ when an assignment on an attr is tried.



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/fit/action_fixture.rb', line 37

def enter
  method_name = Fixture.camel @cells.more.text
  parameter = @cells.more.more.text
  adapter = TypeAdapter.for(@@actor, method_name, false)
  adapter.type = @@actor.class.[method_name]
  argument = adapter.parse(parameter)
  m = @@actor.method method_name
  if m.arity == 1
    @@actor.send(method_name, argument)
  else
    adapter.set argument
  end
end

#pressObject



51
52
53
54
# File 'lib/fit/action_fixture.rb', line 51

def press
  method_name = Fixture.camel @cells.more.text
  @@actor.send method_name
end

#startObject



29
30
31
32
# File 'lib/fit/action_fixture.rb', line 29

def start
  klass = find_class @cells.more.text # using reflection
  @@actor = klass.new
end