Sha256: 4390306eae99695eedabd7428965c8723aef7473516b08eabe5a3c34937c14ad

Contents?: true

Size: 1.38 KB

Versions: 27

Compression:

Stored size: 1.38 KB

Contents

module Cucumber
  module Formatter

    module SpecHelperDsl
      attr_reader :feature_content, :step_defs, :feature_filename

      def define_feature(string, feature_file = 'spec.feature')
        @feature_content = string
        @feature_filename = feature_file
      end

      def define_steps(&block)
        @step_defs = block
      end
    end

    module SpecHelper
      def run_defined_feature
        define_steps
        features = load_features(self.class.feature_content || raise("No feature content defined!"))
        run(features)
      end

      def step_mother
        @step_mother ||= Runtime.new
      end

      def load_features(content)
        feature_file = FeatureFile.new(self.class.feature_filename, content)
        features = 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
        return unless step_defs = self.class.step_defs
        rb = step_mother.load_programming_language('rb')
        dsl = Object.new
        dsl.extend RbSupport::RbDsl
        dsl.instance_exec &step_defs
      end
    end
  end
end

Version data entries

27 entries across 25 versions & 2 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/cucumber-1.3.18/spec/cucumber/formatter/spec_helper.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/cucumber-1.3.16/spec/cucumber/formatter/spec_helper.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/cucumber-1.3.18/spec/cucumber/formatter/spec_helper.rb
cucumber-1.3.20 spec/cucumber/formatter/spec_helper.rb
cucumber-1.3.19 spec/cucumber/formatter/spec_helper.rb
cucumber-1.3.18 spec/cucumber/formatter/spec_helper.rb
cucumber-1.3.17 spec/cucumber/formatter/spec_helper.rb
cucumber-1.3.16 spec/cucumber/formatter/spec_helper.rb
cucumber-1.3.15 spec/cucumber/formatter/spec_helper.rb
cucumber-1.3.14 spec/cucumber/formatter/spec_helper.rb
cucumber-1.3.13 spec/cucumber/formatter/spec_helper.rb
cucumber-1.3.12 spec/cucumber/formatter/spec_helper.rb
cucumber-1.3.11 spec/cucumber/formatter/spec_helper.rb
cucumber-1.3.10 spec/cucumber/formatter/spec_helper.rb
cucumber-1.3.9 spec/cucumber/formatter/spec_helper.rb
cucumber-1.3.8 spec/cucumber/formatter/spec_helper.rb
cucumber-1.3.7 spec/cucumber/formatter/spec_helper.rb
cucumber-1.3.6 spec/cucumber/formatter/spec_helper.rb
cucumber-1.3.5 spec/cucumber/formatter/spec_helper.rb
cucumber-1.3.4 spec/cucumber/formatter/spec_helper.rb