Sha256: 30ab0fa0493dcd7c1b56db1dd3575db55b5c1658852d47ec4d696b0de95c9929

Contents?: true

Size: 733 Bytes

Versions: 4

Compression:

Stored size: 733 Bytes

Contents

module Cucumberator::Commands
  class Undo
    class << self
      def perform(scenario, step_line, last_input, saved_stack, *args, &block)
        if saved_stack.empty?
          puts "There's nothing to revert yet"
          return false
        end

        new(scenario, step_line, saved_stack)
        false
      end
    end

    def initialize(scenario, step_line, saved_stack)
      @feature_file = Cucumberator::FeatureFile.new(scenario)
      lines = @feature_file.lines

      remove_line, remove_string = saved_stack.pop
      lines.delete_at(remove_line - 1)
      @feature_file.overwrite(lines.join)
      step_line.decrement!

      puts "Removed `#{remove_string.to_s.strip}` from #{@feature_file}"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cucumberator-1.0.3 lib/cucumberator/commands/undo.rb
cucumberator-1.0.2 lib/cucumberator/commands/undo.rb
cucumberator-1.0.1 lib/cucumberator/commands/undo.rb
cucumberator-1.0.0 lib/cucumberator/commands/undo.rb