| Class | Spec::Story::Runner::PlainTextStoryRunner |
| In: |
lib/spec/story/runner/plain_text_story_runner.rb
|
| Parent: | Object |
You can initialize a PlainTextStoryRunner with the path to the story file or a block, in which you can define the path using load.
PlainTextStoryRunner.new('path/to/file')
PlainTextStoryRunner.new do |runner|
runner.load 'path/to/file'
end
# File lib/spec/story/runner/plain_text_story_runner.rb, line 15
15: def initialize(*args)
16: @options = Hash === args.last ? args.pop : {}
17: @story_file = args.empty? ? nil : args.shift
18: yield self if block_given?
19: end
# File lib/spec/story/runner/plain_text_story_runner.rb, line 21
21: def []=(key, value)
22: @options[key] = value
23: end
# File lib/spec/story/runner/plain_text_story_runner.rb, line 25
25: def load(path)
26: @story_file = path
27: end
# File lib/spec/story/runner/plain_text_story_runner.rb, line 29
29: def run(story_runner=Spec::Story::Runner.story_runner)
30: raise "You must set a path to the file with the story. See the RDoc." if @story_file.nil?
31: mediator = Spec::Story::Runner::StoryMediator.new(steps, story_runner, @options)
32: parser = Spec::Story::Runner::StoryParser.new(mediator)
33:
34: story_text = File.read(@story_file)
35: parser.parse(story_text.split("\n"))
36:
37: mediator.run_stories
38: end