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
27
# File 'lib/cucumber/jbehave.rb', line 23

def initialize(jbehave_steps, jbehave_candidate_step)
  @jbehave_steps = jbehave_steps
  @jbehave_candidate_step = jbehave_candidate_step
  @regexp = Regexp.new(jbehave_candidate_step.pattern.pattern)
end

Instance Method Details

#file_colon_lineObject



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

def file_colon_line
  @jbehave_steps.java_class.name
end

#format_args(step_name, format) ⇒ Object



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

def format_args(step_name, format)
  step_name.gzub(@regexp, format)
end

#invoke(world, args, step_name) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/cucumber/jbehave.rb', line 45

def invoke(world, args, step_name)
  step = @jbehave_candidate_step.createFrom("Given #{step_name}") # JBehave doesn't care about the adverb.
  step = @jbehave_candidate_step.__send__(:createStep, "Given #{step_name}", args) # JBehave doesn't care about the adverb.

  result = step.perform
  result.describeTo(Reporter)
end

#step_match(name_to_match, name_to_report) ⇒ Object



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

def step_match(name_to_match, name_to_report)
  if(match = name_to_match.match(@regexp))
    StepMatch.new(self, name_to_match, name_to_report, match.captures)
  else
    nil
  end
end