Class: Cucumberator::Commands::Next

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumberator/commands/next.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scenario, step_line) ⇒ Next

Returns a new instance of Next.



9
10
11
12
# File 'lib/cucumberator/commands/next.rb', line 9

def initialize(scenario, step_line)
  @scenario, @step_line = scenario, step_line
  @steps = Cucumberator::Steps.new(@scenario)
end

Class Method Details

.perform(scenario, step_line, *args, &block) ⇒ Object



4
5
6
# File 'lib/cucumberator/commands/next.rb', line 4

def perform(scenario, step_line, *args, &block)
  new(scenario, step_line).next_step
end

Instance Method Details

#detect_next_stepObject



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cucumberator/commands/next.rb', line 26

def detect_next_step
  next_step = nil

  @scenario.steps.each do |step|
    if step.status == :skipped and not step.backtrace_line["Then I will write new steps"]
      next_step = step
      break
    end
  end

  next_step
end

#next_stepObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/cucumberator/commands/next.rb', line 14

def next_step
  if next_step = detect_next_step
    puts next_step.backtrace_line
    @steps.current_visitor.visit_step(next_step)
    @step_line.set(next_step.file_colon_line.split(':').last.to_i)
    false
  else
    puts ":: Looks like it's the end of feature file. Happy coding! <3"
    true
  end
end