Module: Botrytis::CucumberIntegration

Defined in:
lib/botrytis/cucumber.rb

Defined Under Namespace

Modules: SemanticStepMatcher, StepDefinitionCollector Classes: StepDefinitionAdapter

Constant Summary collapse

@@step_definitions =
[]
@@semantic_matcher =
nil
@@semantic_matches_count =
0
@@total_step_attempts =
0

Class Method Summary collapse

Class Method Details

.add_step_definition(step_def) ⇒ Object



60
61
62
63
64
# File 'lib/botrytis/cucumber.rb', line 60

def self.add_step_definition(step_def)
  # Create an adapter to make the step definition compatible with semantic matcher
  adapter = StepDefinitionAdapter.new(step_def)
  @@step_definitions << adapter
end

.install!Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/botrytis/cucumber.rb', line 11

def self.install!
  # Hook into step matching process instead of undefined creation
  Cucumber::Glue::RegistryAndMore.prepend(SemanticStepMatcher)
  
  # Hook into step definition registration to collect them
  Cucumber::Glue::StepDefinition.prepend(StepDefinitionCollector)
  
  # Initialize semantic matcher
  @@semantic_matcher = Botrytis::SemanticMatcher.new
end


46
47
48
49
50
# File 'lib/botrytis/cucumber.rb', line 46

def self.print_summary
  if @@semantic_matches_count > 0
    puts "\nšŸŽÆ Botrytis Semantic Matching Summary: #{@@semantic_matches_count} fuzzy matches found"
  end
end

.record_semantic_match!Object



30
31
32
# File 'lib/botrytis/cucumber.rb', line 30

def self.record_semantic_match!
  @@semantic_matches_count += 1
end

.record_step_attempt!Object



34
35
36
# File 'lib/botrytis/cucumber.rb', line 34

def self.record_step_attempt!
  @@total_step_attempts += 1
end

.semantic_matcherObject



26
27
28
# File 'lib/botrytis/cucumber.rb', line 26

def self.semantic_matcher
  @@semantic_matcher
end

.semantic_matches_countObject



38
39
40
# File 'lib/botrytis/cucumber.rb', line 38

def self.semantic_matches_count
  @@semantic_matches_count
end

.step_definitionsObject



22
23
24
# File 'lib/botrytis/cucumber.rb', line 22

def self.step_definitions
  @@step_definitions
end

.total_step_attemptsObject



42
43
44
# File 'lib/botrytis/cucumber.rb', line 42

def self.total_step_attempts
  @@total_step_attempts
end