Sha256: 2b58082d73bdb6b9f09ca351619a2222a9208efe024b9452b915e0846b5b8857

Contents?: true

Size: 1.42 KB

Versions: 47

Compression:

Stored size: 1.42 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(story_runner=Spec::Story::Runner.story_runner)
          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, 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

47 entries across 47 versions & 10 rubygems

Version Path
dchelimsky-rspec-1.1.10 lib/spec/story/runner/plain_text_story_runner.rb
dchelimsky-rspec-1.1.11.1 lib/spec/story/runner/plain_text_story_runner.rb
dchelimsky-rspec-1.1.11.2 lib/spec/story/runner/plain_text_story_runner.rb
dchelimsky-rspec-1.1.11.3 lib/spec/story/runner/plain_text_story_runner.rb
dchelimsky-rspec-1.1.11.4 lib/spec/story/runner/plain_text_story_runner.rb
dchelimsky-rspec-1.1.11.5 lib/spec/story/runner/plain_text_story_runner.rb
dchelimsky-rspec-1.1.11.6 lib/spec/story/runner/plain_text_story_runner.rb
dchelimsky-rspec-1.1.11.7 lib/spec/story/runner/plain_text_story_runner.rb
dchelimsky-rspec-1.1.11 lib/spec/story/runner/plain_text_story_runner.rb
dchelimsky-rspec-stories-1.0.0 lib/spec/story/runner/plain_text_story_runner.rb
jnstq-acts_as_sms-0.1.0 test/vendor/plugins/rspec/lib/spec/story/runner/plain_text_story_runner.rb
jnstq-acts_as_sms-0.1.1 test/vendor/plugins/rspec/lib/spec/story/runner/plain_text_story_runner.rb
jnstq-acts_as_sms-0.1.3 test/vendor/plugins/rspec/lib/spec/story/runner/plain_text_story_runner.rb
jnstq-acts_as_sms-0.1.4 test/vendor/plugins/rspec/lib/spec/story/runner/plain_text_story_runner.rb
samstokes-rspec-stories-1.0.1 lib/spec/story/runner/plain_text_story_runner.rb
samstokes-rspec-stories-1.0.2 lib/spec/story/runner/plain_text_story_runner.rb
merb-core-1.1.3 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/lib/spec/story/runner/plain_text_story_runner.rb
merb-core-1.1.2 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/lib/spec/story/runner/plain_text_story_runner.rb
merb-core-1.1.1 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/lib/spec/story/runner/plain_text_story_runner.rb
merb-core-1.1.0 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/lib/spec/story/runner/plain_text_story_runner.rb