1 require File.dirname(__FILE__) + '/../../spec_helper.rb'
6 describe Configuration do
8 @config = Configuration.new
9 @example_group = mock("example_group")
12 describe "#mock_with" do
14 it "should default mock framework to rspec" do
15 @config.mock_framework.should =~ /\/plugins\/mock_frameworks\/rspec$/
18 it "should let you set rspec mocking explicitly" do
19 @config.mock_with(:rspec)
20 @config.mock_framework.should =~ /\/plugins\/mock_frameworks\/rspec$/
23 it "should let you set mocha" do
24 @config.mock_with(:mocha)
25 @config.mock_framework.should =~ /\/plugins\/mock_frameworks\/mocha$/
28 it "should let you set flexmock" do
29 @config.mock_with(:flexmock)
30 @config.mock_framework.should =~ /\/plugins\/mock_frameworks\/flexmock$/
33 it "should let you set rr" do
34 @config.mock_with(:rr)
35 @config.mock_framework.should =~ /\/plugins\/mock_frameworks\/rr$/
38 it "should let you set an arbitrary adapter module" do
40 @config.mock_with(adapter)
41 @config.mock_framework.should == adapter
45 describe "#include" do
48 @original_configuration = Spec::Runner.configuration
49 spec_configuration = @config
50 Spec::Runner.instance_eval {@configuration = spec_configuration}
51 @example_group_class = Class.new(ExampleGroup) do
53 def this_class_has_special_methods
57 ExampleGroupFactory.register(:foobar, @example_group_class)
61 original_configuration = @original_configuration
62 Spec::Runner.instance_eval {@configuration = original_configuration}
63 ExampleGroupFactory.reset
66 it "should include the submitted module in ExampleGroup subclasses" do
69 Class.new(@example_group_class).included_modules.should include(mod)
72 it "should let you define modules to be included for a specific type" do
74 @config.include mod, :type => :foobar
75 Class.new(@example_group_class).included_modules.should include(mod)
78 it "should not include modules in a type they are not intended for" do
80 @other_example_group_class = Class.new(ExampleGroup)
81 ExampleGroupFactory.register(:baz, @other_example_group_class)
83 @config.include mod, :type => :foobar
85 Class.new(@other_example_group_class).included_modules.should_not include(mod)
92 describe Configuration do
95 @config = Configuration.new
96 @special_example_group = Class.new(ExampleGroup)
97 @special_child_example_group = Class.new(@special_example_group)
98 @nonspecial_example_group = Class.new(ExampleGroup)
99 ExampleGroupFactory.register(:special, @special_example_group)
100 ExampleGroupFactory.register(:special_child, @special_child_example_group)
101 ExampleGroupFactory.register(:non_special, @nonspecial_example_group)
102 @example_group = @special_child_example_group.describe "Special Example Group"
103 @unselected_example_group = Class.new(@nonspecial_example_group).describe "Non Special Example Group"
107 ExampleGroupFactory.reset
110 describe "#prepend_before" do
111 it "prepends the before block on all instances of the passed in type" do
113 @config.prepend_before(:all) do
114 order << :prepend__before_all
116 @config.prepend_before(:all, :type => :special) do
117 order << :special_prepend__before_all
119 @config.prepend_before(:all, :type => :special_child) do
120 order << :special_child_prepend__before_all
122 @config.prepend_before(:each) do
123 order << :prepend__before_each
125 @config.prepend_before(:each, :type => :special) do
126 order << :special_prepend__before_each
128 @config.prepend_before(:each, :type => :special_child) do
129 order << :special_child_prepend__before_each
131 @config.prepend_before(:all, :type => :non_special) do
132 order << :special_prepend__before_all
134 @config.prepend_before(:each, :type => :non_special) do
135 order << :special_prepend__before_each
137 @example_group.it "calls prepend_before" do
142 :prepend__before_all,
143 :special_prepend__before_all,
144 :special_child_prepend__before_all,
145 :prepend__before_each,
146 :special_prepend__before_each,
147 :special_child_prepend__before_each
152 describe "#append_before" do
154 it "calls append_before on the type" do
156 @config.append_before(:all) do
157 order << :append_before_all
159 @config.append_before(:all, :type => :special) do
160 order << :special_append_before_all
162 @config.append_before(:all, :type => :special_child) do
163 order << :special_child_append_before_all
165 @config.append_before(:each) do
166 order << :append_before_each
168 @config.append_before(:each, :type => :special) do
169 order << :special_append_before_each
171 @config.append_before(:each, :type => :special_child) do
172 order << :special_child_append_before_each
174 @config.append_before(:all, :type => :non_special) do
175 order << :special_append_before_all
177 @config.append_before(:each, :type => :non_special) do
178 order << :special_append_before_each
180 @example_group.it "calls append_before" do
186 :special_append_before_all,
187 :special_child_append_before_all,
189 :special_append_before_each,
190 :special_child_append_before_each
195 describe "#prepend_after" do
197 it "prepends the after block on all instances of the passed in type" do
199 @config.prepend_after(:all) do
200 order << :prepend__after_all
202 @config.prepend_after(:all, :type => :special) do
203 order << :special_prepend__after_all
205 @config.prepend_after(:all, :type => :special) do
206 order << :special_child_prepend__after_all
208 @config.prepend_after(:each) do
209 order << :prepend__after_each
211 @config.prepend_after(:each, :type => :special) do
212 order << :special_prepend__after_each
214 @config.prepend_after(:each, :type => :special) do
215 order << :special_child_prepend__after_each
217 @config.prepend_after(:all, :type => :non_special) do
218 order << :special_prepend__after_all
220 @config.prepend_after(:each, :type => :non_special) do
221 order << :special_prepend__after_each
223 @example_group.it "calls prepend_after" do
228 :special_child_prepend__after_each,
229 :special_prepend__after_each,
230 :prepend__after_each,
231 :special_child_prepend__after_all,
232 :special_prepend__after_all,
238 describe "#append_after" do
240 it "calls append_after on the type" do
242 @config.append_after(:all) do
243 order << :append__after_all
245 @config.append_after(:all, :type => :special) do
246 order << :special_append__after_all
248 @config.append_after(:all, :type => :special_child) do
249 order << :special_child_append__after_all
251 @config.append_after(:each) do
252 order << :append__after_each
254 @config.append_after(:each, :type => :special) do
255 order << :special_append__after_each
257 @config.append_after(:each, :type => :special_child) do
258 order << :special_child_append__after_each
260 @config.append_after(:all, :type => :non_special) do
261 order << :non_special_append_after_all
263 @config.append_after(:each, :type => :non_special) do
264 order << :non_special_append_after_each
266 @example_group.it "calls append_after" do
271 :special_child_append__after_each,
272 :special_append__after_each,
274 :special_child_append__after_all,
275 :special_append__after_all,