Sha256: 02651d157b2ee94ac6bf55e6f71cd7b961fa409e8cc5d704a9c9926008228faf

Contents?: true

Size: 1.27 KB

Versions: 18

Compression:

Stored size: 1.27 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
        features.add_feature feature_file.parse(@step_mother, {})
        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

18 entries across 18 versions & 4 rubygems

Version Path
cucumber-0.5.3 spec/cucumber/formatter/spec_helper.rb
cucumber-0.5.2 spec/cucumber/formatter/spec_helper.rb
cucumber-0.5.1 spec/cucumber/formatter/spec_helper.rb
cucumber-0.5.0 spec/cucumber/formatter/spec_helper.rb
cucumber-0.4.5.rc2 spec/cucumber/formatter/spec_helper.rb
kbaum-cucumber-0.4.5.pre spec/cucumber/formatter/spec_helper.rb
cucumber-0.4.5.rc1 spec/cucumber/formatter/spec_helper.rb
middleman-0.10.17 vendor/gems/gems/cucumber-0.4.4/spec/cucumber/formatter/spec_helper.rb
middleman-0.10.16 vendor/gems/gems/cucumber-0.4.4/spec/cucumber/formatter/spec_helper.rb
middleman-0.10.15 vendor/gems/gems/cucumber-0.4.4/spec/cucumber/formatter/spec_helper.rb
rackjour-0.1.8 vendor/gems/gems/cucumber-0.4.4/spec/cucumber/formatter/spec_helper.rb
middleman-0.10.14 vendor/gems/gems/cucumber-0.4.4/spec/cucumber/formatter/spec_helper.rb
cucumber-0.4.4 spec/cucumber/formatter/spec_helper.rb
cucumber-0.4.3 spec/cucumber/formatter/spec_helper.rb
cucumber-0.4.2 spec/cucumber/formatter/spec_helper.rb
cucumber-0.4.1 spec/cucumber/formatter/spec_helper.rb
cucumber-0.4.0 spec/cucumber/formatter/spec_helper.rb
cucumber-0.4.0.rc1 spec/cucumber/formatter/spec_helper.rb