Module: CucumberTree

Defined in:
lib/cucumber_tree.rb,
lib/cucumber_tree/version.rb,
lib/cucumber_tree/temp_dir.rb,
lib/cucumber_tree/handlers/url.rb,
lib/cucumber_tree/handlers/base.rb,
lib/cucumber_tree/handlers/cookies.rb,
lib/cucumber_tree/handlers/database.rb,
lib/cucumber_tree/handlers/variables.rb,
lib/cucumber_tree/handlers/databases/sqlite.rb,
lib/cucumber_tree/handlers/databases/postgresql.rb

Defined Under Namespace

Modules: Handler Classes: TempDir

Constant Summary collapse

VERSION =
"0.0.1"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.handler_classesObject

Returns the value of attribute handler_classes.



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

def handler_classes
  @handler_classes
end

.handler_instancesObject

Returns the value of attribute handler_instances.



15
16
17
# File 'lib/cucumber_tree.rb', line 15

def handler_instances
  @handler_instances
end

Class Method Details

.load_snapshot(world, scenario) ⇒ Object



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

def load_snapshot(world, scenario)
  parent_feature = scenario.feature.file.gsub(/\A(.*)\/.*(\.feature)\z/, '\1\2')
  snapshot = snapshots[parent_feature]
  instantiate_handlers(world, scenario)
  if snapshot.present?
    handler_instances.each do |handler|
      handler.load(snapshot)
    end
  end
end

.register_handler(*handlers) ⇒ Object



44
45
46
47
# File 'lib/cucumber_tree.rb', line 44

def register_handler(*handlers)
  self.handler_classes ||= []
  self.handler_classes += handlers
end

.save_snapshot(world, scenario) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/cucumber_tree.rb', line 29

def save_snapshot(world, scenario)
  feature_file = scenario.feature.file
  if is_parent_feature?(feature_file)
    snapshots[feature_file] = {}.tap do |snapshot|
      handler_instances.each do |handler|
        handler.save(snapshot)
      end
    end
  end
end

.setupObject



40
41
42
# File 'lib/cucumber_tree.rb', line 40

def setup
  TempDir.clear!
end