1 require File.dirname(__FILE__) + '/../../spec_helper'
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
10 behaviour.superclass.should == Spec::Rails::Example::ModelExample
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'
17 behaviour.superclass.should == Spec::Rails::Example::ModelExample
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'
24 behaviour.superclass.should == Spec::Rails::Example::ModelExample
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'
31 behaviour.superclass.should == Spec::Rails::Example::RailsExample
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'
38 behaviour.superclass.should == Spec::Rails::Example::RailsExample
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
45 behaviour.superclass.should == Spec::Rails::Example::ViewExample
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'
52 behaviour.superclass.should == Spec::Rails::Example::ViewExample
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'
59 behaviour.superclass.should == Spec::Rails::Example::ViewExample
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
66 behaviour.superclass.should == Spec::Rails::Example::HelperExample
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'
73 behaviour.superclass.should == Spec::Rails::Example::HelperExample
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'
80 behaviour.superclass.should == Spec::Rails::Example::HelperExample
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
87 behaviour.superclass.should == Spec::Rails::Example::ControllerExample
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'
94 behaviour.superclass.should == Spec::Rails::Example::ControllerExample
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'
101 behaviour.superclass.should == Spec::Rails::Example::ControllerExample
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
108 behaviour.superclass.should == Spec::Rails::Example::ControllerExample