changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec/spec/spec/example/example_runner_spec.rb

changeset 15: 64acf98d15f4
author: moriq@moriq.com
date: Mon Mar 10 10:12:58 2008 +0900 (16 years ago)
permissions: -rw-r--r--
description: add plugins rspec
1require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
3module Spec
4 module Example
5 # describe "Spec::Example::ExampleRunner", "#run", :shared => true do
6 # before(:each) do
7 # @options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new)
8 # @reporter = ::Spec::Runner::Reporter.new(@options)
9 # @options.reporter = @reporter
10 # @example_group_class = Class.new(ExampleGroup) do
11 # plugin_mock_framework
12 # describe("Some Examples")
13 # end
14 # end
15 #
16 # def create_runner(example_definition)
17 # example = @example_group_class.new(example_definition)
18 # runner = ExampleGroup.new(@options, example)
19 # runner.stub!(:verify_mocks)
20 # runner.stub!(:teardown_mocks)
21 # runner
22 # end
23 # end
24 #
25 # describe ExampleRunner, "#run with blank passing example" do
26 # it_should_behave_like "Spec::Example::ExampleRunner#run"
27 #
28 # before do
29 # @e = @example_group_class.it("example") {}
30 # @runner = create_runner(@e)
31 # end
32 #
33 # it "should send reporter example_started" do
34 # @reporter.should_receive(:example_started).with(equal(@e))
35 # @runner.run
36 # end
37 #
38 # it "should report its name for dry run" do
39 # @options.dry_run = true
40 # @reporter.should_receive(:example_finished).with(equal(@e), nil)
41 # @runner.run
42 # end
43 #
44 # it "should report success" do
45 # @reporter.should_receive(:example_finished).with(equal(@e), nil)
46 # @runner.run
47 # end
48 # end
49 #
50 # describe ExampleRunner, "#run with a failing example" do
51 # predicate_matchers[:is_a] = [:is_a?]
52 # it_should_behave_like "Spec::Example::ExampleRunner#run"
53 #
54 # before do
55 # @e = @example_group_class.it("example") do
56 # (2+2).should == 5
57 # end
58 # @runner = create_runner(@e)
59 # end
60 #
61 # it "should report failure due to failure" do
62 # @reporter.should_receive(:example_finished).with(
63 # equal(@e),
64 # is_a(Spec::Expectations::ExpectationNotMetError)
65 # )
66 # @runner.run
67 # end
68 # end
69 #
70 # describe ExampleRunner, "#run with a erroring example" do
71 # it_should_behave_like "Spec::Example::ExampleRunner#run"
72 #
73 # before do
74 # @error = error = NonStandardError.new("in body")
75 # @example_definition = @example_group_class.it("example") do
76 # raise(error)
77 # end
78 # @runner = create_runner(@example_definition)
79 # end
80 #
81 # it "should report failure due to error" do
82 # @reporter.should_receive(:example_finished).with(
83 # equal(@example_definition),
84 # @error
85 # )
86 # @runner.run
87 # end
88 #
89 # it "should run after_each block" do
90 # @example_group_class.after(:each) do
91 # raise("in after_each")
92 # end
93 # @reporter.should_receive(:example_finished) do |example_definition, error|
94 # example_definition.should equal(@example_definition)
95 # error.message.should eql("in body")
96 # end
97 # @runner.run
98 # end
99 # end
100 #
101 # describe ExampleRunner, "#run where after_each fails" do
102 # it_should_behave_like "Spec::Example::ExampleRunner#run"
103 #
104 # before do
105 # @example_ran = example_ran = false
106 # @example_definition = @example_group_class.it("should not run") do
107 # example_ran = true
108 # end
109 # @runner = create_runner(@example_definition)
110 # @example_group_class.after(:each) { raise(NonStandardError.new("in after_each")) }
111 # end
112 #
113 # it "should report failure location when in after_each" do
114 # @reporter.should_receive(:example_finished) do |example_definition, error|
115 # example_definition.should equal(@example_definition)
116 # error.message.should eql("in after_each")
117 # end
118 # @runner.run
119 # end
120 # end
121 #
122 # describe ExampleRunner, "#run with use cases" do
123 # predicate_matchers[:is_a] = [:is_a?]
124 # it_should_behave_like "Spec::Example::ExampleRunner#run"
125 #
126 # it "should report NO NAME when told to use generated description with --dry-run" do
127 # @options.dry_run = true
128 # example_definition = @example_group_class.it() do
129 # 5.should == 5
130 # end
131 # runner = create_runner(example_definition)
132 #
133 # @reporter.should_receive(:example_finished) do |example_definition, error|
134 # example_definition.description.should == "NO NAME (Because of --dry-run)"
135 # end
136 # runner.run
137 # end
138 #
139 # it "should report given name if present with --dry-run" do
140 # @options.dry_run = true
141 # example_definition = @example_group_class.it("example name") do
142 # 5.should == 5
143 # end
144 # runner = create_runner(example_definition)
145 #
146 # @reporter.should_receive(:example_finished) do |example_definition, error|
147 # example_definition.description.should == "example name"
148 # end
149 # runner.run
150 # end
151 #
152 # it "should report NO NAME when told to use generated description with no expectations" do
153 # example_definition = @example_group_class.it() {}
154 # runner = create_runner(example_definition)
155 # @reporter.should_receive(:example_finished) do |example, error|
156 # example.description.should == "NO NAME (Because there were no expectations)"
157 # end
158 # runner.run
159 # end
160 #
161 # it "should report NO NAME when told to use generated description and matcher fails" do
162 # example_definition = @example_group_class.it() do
163 # 5.should "" # Has no matches? method..
164 # end
165 # runner = create_runner(example_definition)
166 #
167 # @reporter.should_receive(:example_finished) do |example, error|
168 # example_definition.description.should == "NO NAME (Because of Error raised in matcher)"
169 # end
170 # runner.run
171 # end
172 #
173 # it "should report generated description when told to and it is available" do
174 # example_definition = @example_group_class.it() {
175 # 5.should == 5
176 # }
177 # runner = create_runner(example_definition)
178 #
179 # @reporter.should_receive(:example_finished) do |example_definition, error|
180 # example_definition.description.should == "should == 5"
181 # end
182 # runner.run
183 # end
184 #
185 # it "should unregister description_generated callback (lest a memory leak should build up)" do
186 # example_definition = @example_group_class.it("something")
187 # runner = create_runner(example_definition)
188 #
189 # Spec::Matchers.should_receive(:example_finished)
190 # runner.run
191 # end
192 # end
193 end
194end