Class: Knapsack::Adapters::SpinachAdapter

Inherits:
BaseAdapter
  • Object
show all
Defined in:
lib/knapsack/adapters/spinach_adapter.rb

Constant Summary collapse

TEST_DIR_PATTERN =
'features/**{,/*/**}/*.feature'
REPORT_PATH =
'knapsack_spinach_report.json'

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseAdapter

bind, #bind

Class Method Details

.test_path(scenario) ⇒ Object



38
39
40
# File 'lib/knapsack/adapters/spinach_adapter.rb', line 38

def self.test_path(scenario)
  scenario.feature.filename
end

Instance Method Details

#bind_report_generatorObject



22
23
24
25
26
27
# File 'lib/knapsack/adapters/spinach_adapter.rb', line 22

def bind_report_generator
  ::Spinach.hooks.after_run do
    Knapsack.report.save
    Knapsack.logger.info(Presenter.report_details)
  end
end

#bind_time_offset_warningObject



29
30
31
32
33
34
35
36
# File 'lib/knapsack/adapters/spinach_adapter.rb', line 29

def bind_time_offset_warning
  ::Spinach.hooks.after_run do
    Knapsack.logger.log(
      Presenter.time_offset_log_level,
      Presenter.time_offset_warning
    )
  end
end

#bind_time_trackerObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/knapsack/adapters/spinach_adapter.rb', line 7

def bind_time_tracker
  ::Spinach.hooks.before_scenario do |scenario_data, step_definitions|
    Knapsack.tracker.test_path = SpinachAdapter.test_path(scenario_data)
    Knapsack.tracker.start_timer
  end

  ::Spinach.hooks.after_scenario do
    Knapsack.tracker.stop_timer
  end

  ::Spinach.hooks.after_run do
    Knapsack.logger.info(Presenter.global_time)
  end
end