Class: Frogger::Frog

Inherits:
Object
  • Object
show all
Defined in:
lib/frogger/frog.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scenario, logger = default_logger) ⇒ Frog

Returns a new instance of Frog.



5
6
7
8
9
# File 'lib/frogger/frog.rb', line 5

def initialize(scenario, logger = default_logger)
  @scenario   = scenario
  @logger     = logger
  @step_index = 0
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



2
3
4
# File 'lib/frogger/frog.rb', line 2

def logger
  @logger
end

#scenarioObject (readonly)

Returns the value of attribute scenario.



2
3
4
# File 'lib/frogger/frog.rb', line 2

def scenario
  @scenario
end

#step_indexObject

Returns the value of attribute step_index.



3
4
5
# File 'lib/frogger/frog.rb', line 3

def step_index
  @step_index
end

Instance Method Details

#log_scenarioObject



11
12
13
14
15
16
# File 'lib/frogger/frog.rb', line 11

def log_scenario
  padding = max_length - 2 - scenario.name.length
  logger.debug(
    "\n\n  #{scenario.name.upcase}#{ ' ' * padding }  ".black_on_green
  )
end

#log_stepObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/frogger/frog.rb', line 18

def log_step
  return if step.nil?
  
  step_to_s = "#{step.keyword}#{step.name}"
  padding = [max_length - 4 - step_to_s.length, 0].max
  
  logger.debug "\n    #{ step_to_s }#{ ' ' * padding }  ".black_on_yellow
  
  self.step_index += 1
end

#scenario_outline?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/frogger/frog.rb', line 29

def scenario_outline?
  scenario.class == Cucumber::Ast::OutlineTable::ExampleRow
end