Sha256: a823a67494feea958347053ad42875c9471224444a824430f3a0fa80d7e5a86c

Contents?: true

Size: 1.65 KB

Versions: 12

Compression:

Stored size: 1.65 KB

Contents

# frozen_string_literal: true

module Isomorfeus
  module Operation
    module Mixin
      def procedure(gherkin_text)
        feature_line = gherkin_text.include?('Operation: ') ? '' : "Operation: #{self.name}\n"
        scenario_line = feature_line == '' || gherkin_text.include?('Procedure: ') ? '' : "  Procedure: #{self.name} executing\n"
        @procedure = feature_line + scenario_line + gherkin_text
      end

      def gherkin
        @gherkin ||= Isomorfeus::Operation::Gherkin.parse(@procedure)
      end

      def ensure_steps
        @ensure_steps ||= []
      end

      def failure_steps
        @failure_steps ||= []
      end

      def steps
        @steps ||= []
      end

      def First(regular_expression, &block)
        raise "#{self}: First already defined, can only be defined once!" if @first_defined
        @first_defined = true
        steps << [regular_expression, block]
      end

      def Given(regular_expression, &block)
        steps << [regular_expression, block]
      end
      alias :And :Given
      alias :Then :Given
      alias :When :Given

      def Finally(regular_expression, &block)
        raise "#{self}: Finally already defined, can only be defined once!" if @finally_defined
        @finally_defined = true
        steps << [regular_expression, block]
      end

      def Ensure(regular_expression, &block)
        ensure_steps << [regular_expression, block]
      end

      def Failed(regular_expression, &block)
        failure_steps << [regular_expression, block]
      end
      alias :If_failing :Failed
      alias :When_failing :Failed
      alias :If_this_failed :Failed
      alias :If_that_failed :Failed
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
isomorfeus-operation-1.0.0.zeta10 lib/isomorfeus/operation/mixin.rb
isomorfeus-operation-1.0.0.zeta9 lib/isomorfeus/operation/mixin.rb
isomorfeus-operation-1.0.0.zeta8 lib/isomorfeus/operation/mixin.rb
isomorfeus-operation-1.0.0.zeta6 lib/isomorfeus/operation/mixin.rb
isomorfeus-operation-1.0.0.zeta5 lib/isomorfeus/operation/mixin.rb
isomorfeus-operation-1.0.0.zeta4 lib/isomorfeus/operation/mixin.rb
isomorfeus-operation-1.0.0.zeta3 lib/isomorfeus/operation/mixin.rb
isomorfeus-operation-1.0.0.zeta2 lib/isomorfeus/operation/mixin.rb
isomorfeus-operation-1.0.0.zeta1 lib/isomorfeus/operation/mixin.rb
isomorfeus-operation-1.0.0.epsilon4 lib/isomorfeus/operation/mixin.rb
isomorfeus-operation-1.0.0.epsilon3 lib/isomorfeus/operation/mixin.rb
isomorfeus-operation-1.0.0.epsilon2 lib/isomorfeus/operation/mixin.rb