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.



23
24
25
26
# File 'lib/cucumber/jbehave.rb', line 23

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



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

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



33
34
35
# File 'lib/cucumber/jbehave.rb', line 33

def file_colon_line
  @jbehave_steps.java_class.name
end

#format_args(step_name, format) ⇒ Object



37
38
39
40
41
# File 'lib/cucumber/jbehave.rb', line 37

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



28
29
30
31
# File 'lib/cucumber/jbehave.rb', line 28

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



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

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