Upgraded Rails and RSpec
[monkeycharger.git] / vendor / plugins / rspec / rspec_on_rails / spec / rails / dsl / example_group_factory_spec.rb
blobbdd67443625e3fb2b3e6842dc8703f037e5048e6
1 require File.dirname(__FILE__) + '/../../spec_helper'
3 module Spec
4   module Example
5     describe ExampleGroupFactory do
6       it "should return a ModelExample when given :behaviour_type => :model" do
7         behaviour = Spec::Example::ExampleGroupFactory.create_example_group(
8           "name", :behaviour_type => :model
9         ) {}
10         behaviour.superclass.should == Spec::Rails::Example::ModelExample
11       end
13       it "should return a ModelExample when given :spec_path => '/blah/spec/models/'" do
14         behaviour = Spec::Example::ExampleGroupFactory.create_example_group(
15           "name", :spec_path => '/blah/spec/models/blah.rb'
16         ) {}
17         behaviour.superclass.should == Spec::Rails::Example::ModelExample
18       end
20       it "should return a ModelExample when given :spec_path => '\\blah\\spec\\models\\' (windows format)" do
21         behaviour = Spec::Example::ExampleGroupFactory.create_example_group(
22           "name", :spec_path => '\\blah\\spec\\models\\blah.rb'
23         ) {}
24         behaviour.superclass.should == Spec::Rails::Example::ModelExample
25       end
27       it "should return a RailsExample when given :spec_path => '/blah/spec/foo/' (anything other than controllers, views and helpers)" do
28         behaviour = Spec::Example::ExampleGroupFactory.create_example_group(
29           "name", :spec_path => '/blah/spec/foo/blah.rb'
30         ) {}
31         behaviour.superclass.should == Spec::Rails::Example::RailsExample
32       end
34       it "should return a RailsExample when given :spec_path => '\\blah\\spec\\foo\\' (windows format)  (anything other than controllers, views and helpers)" do
35         behaviour = Spec::Example::ExampleGroupFactory.create_example_group(
36           "name", :spec_path => '\\blah\\spec\\foo\\blah.rb'
37         ) {}
38         behaviour.superclass.should == Spec::Rails::Example::RailsExample
39       end
41       it "should return a ViewExample when given :behaviour_type => :model" do
42         behaviour = Spec::Example::ExampleGroupFactory.create_example_group(
43           "name", :behaviour_type => :view
44         ) {}
45         behaviour.superclass.should == Spec::Rails::Example::ViewExample
46       end
48       it "should return a ViewExample when given :spec_path => '/blah/spec/views/'" do
49         behaviour = Spec::Example::ExampleGroupFactory.create_example_group(
50           "name", :spec_path => '/blah/spec/views/blah.rb'
51         ) {}
52         behaviour.superclass.should == Spec::Rails::Example::ViewExample
53       end
55       it "should return a ModelExample when given :spec_path => '\\blah\\spec\\views\\' (windows format)" do
56         behaviour = Spec::Example::ExampleGroupFactory.create_example_group(
57           "name", :spec_path => '\\blah\\spec\\views\\blah.rb'
58         ) {}
59         behaviour.superclass.should == Spec::Rails::Example::ViewExample
60       end
62       it "should return a HelperExample when given :behaviour_type => :helper" do
63         behaviour = Spec::Example::ExampleGroupFactory.create_example_group(
64           "name", :behaviour_type => :helper
65         ) {}
66         behaviour.superclass.should == Spec::Rails::Example::HelperExample
67       end
69       it "should return a HelperExample when given :spec_path => '/blah/spec/helpers/'" do
70         behaviour = Spec::Example::ExampleGroupFactory.create_example_group(
71           "name", :spec_path => '/blah/spec/helpers/blah.rb'
72         ) {}
73         behaviour.superclass.should == Spec::Rails::Example::HelperExample
74       end
76       it "should return a ModelExample when given :spec_path => '\\blah\\spec\\helpers\\' (windows format)" do
77         behaviour = Spec::Example::ExampleGroupFactory.create_example_group(
78           "name", :spec_path => '\\blah\\spec\\helpers\\blah.rb'
79         ) {}
80         behaviour.superclass.should == Spec::Rails::Example::HelperExample
81       end
83       it "should return a ControllerExample when given :behaviour_type => :controller" do
84         behaviour = Spec::Example::ExampleGroupFactory.create_example_group(
85           "name", :behaviour_type => :controller
86         ) {}
87         behaviour.superclass.should == Spec::Rails::Example::ControllerExample
88       end
90       it "should return a ControllerExample when given :spec_path => '/blah/spec/controllers/'" do
91         behaviour = Spec::Example::ExampleGroupFactory.create_example_group(
92           "name", :spec_path => '/blah/spec/controllers/blah.rb'
93         ) {}
94         behaviour.superclass.should == Spec::Rails::Example::ControllerExample
95       end
97       it "should return a ModelExample when given :spec_path => '\\blah\\spec\\controllers\\' (windows format)" do
98         behaviour = Spec::Example::ExampleGroupFactory.create_example_group(
99           "name", :spec_path => '\\blah\\spec\\controllers\\blah.rb'
100         ) {}
101         behaviour.superclass.should == Spec::Rails::Example::ControllerExample
102       end
104       it "should favor the :behaviour_type over the :spec_path" do
105         behaviour = Spec::Example::ExampleGroupFactory.create_example_group(
106           "name", :spec_path => '/blah/spec/models/blah.rb', :behaviour_type => :controller
107         ) {}
108         behaviour.superclass.should == Spec::Rails::Example::ControllerExample
109       end
110     end
111   end