Class: Spec::Story::Runner::PlainTextStoryRunner
- Inherits:
-
Object
- Object
- Spec::Story::Runner::PlainTextStoryRunner
- Defined in:
- lib/spec/story/runner/plain_text_story_runner.rb
Instance Method Summary collapse
- #[]=(key, value) ⇒ Object
-
#initialize(*args) {|_self| ... } ⇒ PlainTextStoryRunner
constructor
You can initialize a PlainTextStoryRunner with the path to the story file or a block, in which you can define the path using load.
- #load(path) ⇒ Object
- #run(story_runner = Spec::Story::Runner.story_runner) ⇒ Object
- #steps {|@step_group| ... } ⇒ Object
Constructor Details
#initialize(*args) {|_self| ... } ⇒ 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
15 16 17 18 19 |
# File 'lib/spec/story/runner/plain_text_story_runner.rb', line 15 def initialize(*args) @options = Hash === args.last ? args.pop : {} @story_file = args.empty? ? nil : args.shift yield self if block_given? end |
Instance Method Details
#[]=(key, value) ⇒ Object
21 22 23 |
# File 'lib/spec/story/runner/plain_text_story_runner.rb', line 21 def []=(key, value) @options[key] = value end |
#load(path) ⇒ Object
25 26 27 |
# File 'lib/spec/story/runner/plain_text_story_runner.rb', line 25 def load(path) @story_file = path end |
#run(story_runner = Spec::Story::Runner.story_runner) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/spec/story/runner/plain_text_story_runner.rb', line 29 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 |