Sha256: 3c17070cc0e5180460b10f8312d9d810e8a6f9d08b70bf1b9dbab110efdadaea

Contents?: true

Size: 1.3 KB

Versions: 6

Compression:

Stored size: 1.3 KB

Contents

module Cucumber
  module Formatter

    module SpecHelperDsl
      attr_reader :feature_content, :step_defs
    
      def define_feature(string)
        @feature_content = string
      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 ||= StepMother.new
      end
      
      def load_features(content)
        feature_file = FeatureFile.new('spec.feature', content)
        features = Ast::Features.new
        feature = feature_file.parse(@step_mother, {})
        features.add_feature(feature)
        features
      end
    
      def run(features)
        # options = { :verbose => true }
        options = {}
        tree_walker = Cucumber::Ast::TreeWalker.new(@step_mother, [@formatter], options, STDOUT)
        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

6 entries across 6 versions & 2 rubygems

Version Path
cucumber-0.6.4 spec/cucumber/formatter/spec_helper.rb
cucumber-0.6.3 spec/cucumber/formatter/spec_helper.rb
davidtrogers-cucumber-0.6.2 spec/cucumber/formatter/spec_helper.rb
cucumber-0.6.2 spec/cucumber/formatter/spec_helper.rb
cucumber-0.6.1 spec/cucumber/formatter/spec_helper.rb
cucumber-0.6.0 spec/cucumber/formatter/spec_helper.rb