Sha256: 4ee2bd2cb223bf935642f1dc87a09830de851e394a7b1f86f7035ccc3308afbc

Contents?: true

Size: 1.39 KB

Versions: 27

Compression:

Stored size: 1.39 KB

Contents

module Spec
  module Story
    module Runner
      class PlainTextStoryRunner
        # You can initialize a PlainTextStoryRunner with the path to the
        # story file or a block, in which you can define the path using load.
        #
        # == Examples
        #   
        #   PlainTextStoryRunner.new('path/to/file')
        #
        #   PlainTextStoryRunner.new do |runner|
        #     runner.load 'path/to/file'
        #   end
        def initialize(*args)
          @options = Hash === args.last ? args.pop : {}
          @story_file = args.empty? ? nil : args.shift
          yield self if block_given?
        end
        
        def []=(key, value)
          @options[key] = value
        end
        
        def load(path)
          @story_file = path
        end
        
        def run
          raise "You must set a path to the file with the story. See the RDoc." if @story_file.nil?
          mediator = Spec::Story::Runner::StoryMediator.new(steps, Spec::Story::Runner.story_runner, @options)
          parser = Spec::Story::Runner::StoryParser.new(mediator)

          story_text = File.read(@story_file)          
          parser.parse(story_text.split("\n"))

          mediator.run_stories
        end
        
        def steps
          @step_group ||= Spec::Story::StepGroup.new
          yield @step_group if block_given?
          @step_group
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 5 rubygems

Version Path
picolena-0.0.99 app_generators/picolena/templates/vendor/plugins/rspec/lib/spec/story/runner/plain_text_story_runner.rb
picolena-0.1.0 rails_plugins/rspec/lib/spec/story/runner/plain_text_story_runner.rb
picolena-0.1.1 rails_plugins/rspec/lib/spec/story/runner/plain_text_story_runner.rb
picolena-0.1.3 rails_plugins/rspec/lib/spec/story/runner/plain_text_story_runner.rb
picolena-0.1.4 rails_plugins/rspec/lib/spec/story/runner/plain_text_story_runner.rb
picolena-0.1.2 rails_plugins/rspec/lib/spec/story/runner/plain_text_story_runner.rb
picolena-0.1.5 rails_plugins/rspec/lib/spec/story/runner/plain_text_story_runner.rb
radiant-0.6.5.1 vendor/plugins/rspec/lib/spec/story/runner/plain_text_story_runner.rb
radiant-0.6.5 vendor/plugins/rspec/lib/spec/story/runner/plain_text_story_runner.rb
radiant-0.6.6 vendor/plugins/rspec/lib/spec/story/runner/plain_text_story_runner.rb
radiant-0.6.7 vendor/plugins/rspec/lib/spec/story/runner/plain_text_story_runner.rb
radiant-0.6.9 vendor/plugins/rspec/lib/spec/story/runner/plain_text_story_runner.rb
radiant-0.6.8 vendor/plugins/rspec/lib/spec/story/runner/plain_text_story_runner.rb
rspec-1.1.0 lib/spec/story/runner/plain_text_story_runner.rb
rspec-1.1.1 lib/spec/story/runner/plain_text_story_runner.rb
rspec-1.1.2 lib/spec/story/runner/plain_text_story_runner.rb
rspec-1.1.3 lib/spec/story/runner/plain_text_story_runner.rb
spree-0.2.0 vendor/plugins/rspec/lib/spec/story/runner/plain_text_story_runner.rb
typo-5.0.2 vendor/plugins/rspec/lib/spec/story/runner/plain_text_story_runner.rb
typo-5.0.1 vendor/plugins/rspec/lib/spec/story/runner/plain_text_story_runner.rb