]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/rspec-1.1.2/spec/spec/story/runner/plain_text_story_runner_spec.rb
Show whether a trace is public or private in the trace list, so that a user can easil...
[rails.git] / vendor / gems / rspec-1.1.2 / spec / spec / story / runner / plain_text_story_runner_spec.rb
1 require File.dirname(__FILE__) + '/../story_helper'
2
3 module Spec
4   module Story
5     module Runner
6       describe PlainTextStoryRunner do
7         before(:each) do
8           StoryParser.stub!(:new).and_return(@parser = mock("parser"))
9           @parser.stub!(:parse).and_return([])
10           File.stub!(:read).with("path").and_return("this\nand that")
11         end
12
13         it "should provide access to steps" do
14           runner = PlainTextStoryRunner.new("path")
15           
16           runner.steps do |add|
17             add.given("baz") {}
18           end
19           
20           runner.steps.find(:given, "baz").should_not be_nil
21         end
22         
23         it "should parse a story file" do
24           runner = PlainTextStoryRunner.new("path")
25           
26           during {
27             runner.run
28           }.expect {
29             @parser.should_receive(:parse).with(["this", "and that"])
30           }
31         end
32         
33         it "should build up a mediator with its own steps and the singleton story_runner" do
34           runner = PlainTextStoryRunner.new("path")
35           Spec::Story::Runner.should_receive(:story_runner).and_return(story_runner = mock("story runner"))
36           Spec::Story::Runner::StoryMediator.should_receive(:new).with(runner.steps, story_runner, {}).
37             and_return(mediator = stub("mediator", :run_stories => nil))
38           runner.run
39         end
40         
41         it "should build up a parser with the mediator" do
42           runner = PlainTextStoryRunner.new("path")
43           Spec::Story::Runner.should_receive(:story_runner).and_return(story_runner = mock("story runner"))
44           Spec::Story::Runner::StoryMediator.should_receive(:new).and_return(mediator = stub("mediator", :run_stories => nil))
45           Spec::Story::Runner::StoryParser.should_receive(:new).with(mediator).and_return(@parser)
46           runner.run
47         end
48         
49         it "should tell the mediator to run the stories" do
50           runner = PlainTextStoryRunner.new("path")
51           mediator = mock("mediator")
52           Spec::Story::Runner::StoryMediator.should_receive(:new).and_return(mediator)
53           mediator.should_receive(:run_stories)
54           runner.run
55         end
56         
57         it "should accept a block instead of a path" do
58           runner = PlainTextStoryRunner.new do |runner|
59             runner.load("path/to/story")
60           end
61           File.should_receive(:read).with("path/to/story").and_return("this\nand that")
62           runner.run
63         end
64         
65         it "should tell you if you try to run with no path set" do
66           runner = PlainTextStoryRunner.new
67           lambda {
68             runner.run
69           }.should raise_error(RuntimeError, "You must set a path to the file with the story. See the RDoc.")
70         end
71         
72         it "should pass options to the mediator" do
73           runner = PlainTextStoryRunner.new("path", :foo => :bar)
74           Spec::Story::Runner::StoryMediator.should_receive(:new).
75             with(anything, anything, :foo => :bar).
76             and_return(mediator = stub("mediator", :run_stories => nil))
77           runner.run
78         end
79         
80         it "should provide access to its options" do
81           runner = PlainTextStoryRunner.new("path")
82           runner[:foo] = :bar
83           Spec::Story::Runner::StoryMediator.should_receive(:new).
84             with(anything, anything, :foo => :bar).
85             and_return(mediator = stub("mediator", :run_stories => nil))
86           runner.run
87         end
88         
89       end
90     end
91   end
92 end