Class: Cucumber::JBehave::JBehaveStepDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/jbehave.rb

Overview

Adapter for JBehave org.jbehave.scenario.steps.CandidateStep

Instance Method Summary collapse

Constructor Details

#initialize(jbehave_steps, jbehave_candidate_step) ⇒ JBehaveStepDefinition

Returns a new instance of JBehaveStepDefinition.



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

def initialize(jbehave_steps, jbehave_candidate_step)
  @jbehave_steps = jbehave_steps
  @jbehave_candidate_step = jbehave_candidate_step
end

Instance Method Details

#execute(step_name, world, *args) ⇒ Object



56
57
58
59
60
# File 'lib/cucumber/jbehave.rb', line 56

def execute(step_name, world, *args)
  step = @jbehave_candidate_step.createFrom("Given #{step_name}")
  result = step.perform
  result.describeTo(JBehave::REPORTER)
end

#file_colon_lineObject



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

def file_colon_line
  @jbehave_steps.java_class.name
end

#format_args(step_name, format) ⇒ Object



44
45
46
47
48
# File 'lib/cucumber/jbehave.rb', line 44

def format_args(step_name, format)
  java_pattern = @jbehave_candidate_step.pattern.pattern
  regexp = Regexp.new(java_pattern)
  step_name.gzub(regexp, format)
end

#match(step_name) ⇒ Object



35
36
37
38
# File 'lib/cucumber/jbehave.rb', line 35

def match(step_name)
  full_text = "Given #{step_name}" # JBehave doesn't distinguish GWT internally :-)
  @jbehave_candidate_step.matches(full_text)
end

#matched_args(step_name) ⇒ Object



50
51
52
53
54
# File 'lib/cucumber/jbehave.rb', line 50

def matched_args(step_name)
  java_pattern = @jbehave_candidate_step.pattern.pattern
  regexp = Regexp.new(java_pattern)
  step_name.match(regexp).captures
end