Sha256: 6c0f69af921bd416a49cf204e70642e8166ed7bf22dffc1e2245e9dd0865329c

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

# NOTE: This file is verbatim "borrowed" from the cucumber source tree:
# <https://github.com/cucumber/cucumber/blob/master/spec/cucumber/formatter/spec_helper.rb>

require 'cucumber'

module Sauce
  module Cucumber
    module SpecHelper
      def run_defined_feature(content)
        features = load_features(content || raise("No feature content defined!"))
        run(features)
      end

      def step_mother
        @step_mother ||= ::Cucumber::Runtime.new
        return @step_mother
      end

      def load_features(content)
        feature_file = ::Cucumber::FeatureFile.new('mock.feature', content)
        features = ::Cucumber::Ast::Features.new
        filters = []
        feature = feature_file.parse(filters, {})
        features.add_feature(feature) if feature
        features
      end

      def run(features)
        configuration = ::Cucumber::Configuration.default
        tree_walker = ::Cucumber::Ast::TreeWalker.new(step_mother, [@formatter], configuration)
        tree_walker.visit_features(features)
      end

      def define_steps(&block)
        rb = step_mother.load_programming_language('rb')
        dsl = Object.new
        dsl.extend ::Cucumber::RbSupport::RbDsl
        dsl.instance_exec &block
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sauce-3.7.2 spec/cucumber_helper.rb
sauce-3.7.1 spec/cucumber_helper.rb
sauce-3.7.0 spec/cucumber_helper.rb