changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec_on_rails/spec/rails/example/example_group_factory_spec.rb

changeset 16: 01fd3f10ae84
author: moriq@moriq.com
date: Mon Mar 10 10:13:18 2008 +0900 (16 years ago)
permissions: -rw-r--r--
description: add plugins rspec_on_rails
1require File.dirname(__FILE__) + '/../../spec_helper'
2
3module Spec
4 module Example
5 describe ExampleGroupFactory do
6 it "should return a ModelExampleGroup when given :type => :model" do
7 example_group = Spec::Example::ExampleGroupFactory.create_example_group(
8 "name", :type => :model
9 ) {}
10 example_group.superclass.should == Spec::Rails::Example::ModelExampleGroup
11 end
12
13 it "should return a ModelExampleGroup when given :spec_path => '/blah/spec/models/'" do
14 example_group = Spec::Example::ExampleGroupFactory.create_example_group(
15 "name", :spec_path => '/blah/spec/models/blah.rb'
16 ) {}
17 example_group.superclass.should == Spec::Rails::Example::ModelExampleGroup
18 end
19
20 it "should return a ModelExampleGroup when given :spec_path => '\\blah\\spec\\models\\' (windows format)" do
21 example_group = Spec::Example::ExampleGroupFactory.create_example_group(
22 "name", :spec_path => '\\blah\\spec\\models\\blah.rb'
23 ) {}
24 example_group.superclass.should == Spec::Rails::Example::ModelExampleGroup
25 end
26
27 it "should return a RailsExampleGroup when given :spec_path => '/blah/spec/foo/' (anything other than controllers, views and helpers)" do
28 example_group = Spec::Example::ExampleGroupFactory.create_example_group(
29 "name", :spec_path => '/blah/spec/foo/blah.rb'
30 ) {}
31 example_group.superclass.should == Spec::Rails::Example::RailsExampleGroup
32 end
33
34 it "should return a RailsExampleGroup when given :spec_path => '\\blah\\spec\\foo\\' (windows format) (anything other than controllers, views and helpers)" do
35 example_group = Spec::Example::ExampleGroupFactory.create_example_group(
36 "name", :spec_path => '\\blah\\spec\\foo\\blah.rb'
37 ) {}
38 example_group.superclass.should == Spec::Rails::Example::RailsExampleGroup
39 end
40
41 it "should return a ViewExampleGroup when given :type => :model" do
42 example_group = Spec::Example::ExampleGroupFactory.create_example_group(
43 "name", :type => :view
44 ) {}
45 example_group.superclass.should == Spec::Rails::Example::ViewExampleGroup
46 end
47
48 it "should return a ViewExampleGroup when given :spec_path => '/blah/spec/views/'" do
49 example_group = Spec::Example::ExampleGroupFactory.create_example_group(
50 "name", :spec_path => '/blah/spec/views/blah.rb'
51 ) {}
52 example_group.superclass.should == Spec::Rails::Example::ViewExampleGroup
53 end
54
55 it "should return a ModelExampleGroup when given :spec_path => '\\blah\\spec\\views\\' (windows format)" do
56 example_group = Spec::Example::ExampleGroupFactory.create_example_group(
57 "name", :spec_path => '\\blah\\spec\\views\\blah.rb'
58 ) {}
59 example_group.superclass.should == Spec::Rails::Example::ViewExampleGroup
60 end
61
62 it "should return a HelperExampleGroup when given :type => :helper" do
63 example_group = Spec::Example::ExampleGroupFactory.create_example_group(
64 "name", :type => :helper
65 ) {}
66 example_group.superclass.should == Spec::Rails::Example::HelperExampleGroup
67 end
68
69 it "should return a HelperExampleGroup when given :spec_path => '/blah/spec/helpers/'" do
70 example_group = Spec::Example::ExampleGroupFactory.create_example_group(
71 "name", :spec_path => '/blah/spec/helpers/blah.rb'
72 ) {}
73 example_group.superclass.should == Spec::Rails::Example::HelperExampleGroup
74 end
75
76 it "should return a ModelExampleGroup when given :spec_path => '\\blah\\spec\\helpers\\' (windows format)" do
77 example_group = Spec::Example::ExampleGroupFactory.create_example_group(
78 "name", :spec_path => '\\blah\\spec\\helpers\\blah.rb'
79 ) {}
80 example_group.superclass.should == Spec::Rails::Example::HelperExampleGroup
81 end
82
83 it "should return a ControllerExampleGroup when given :type => :controller" do
84 example_group = Spec::Example::ExampleGroupFactory.create_example_group(
85 "name", :type => :controller
86 ) {}
87 example_group.superclass.should == Spec::Rails::Example::ControllerExampleGroup
88 end
89
90 it "should return a ControllerExampleGroup when given :spec_path => '/blah/spec/controllers/'" do
91 example_group = Spec::Example::ExampleGroupFactory.create_example_group(
92 "name", :spec_path => '/blah/spec/controllers/blah.rb'
93 ) {}
94 example_group.superclass.should == Spec::Rails::Example::ControllerExampleGroup
95 end
96
97 it "should return a ModelExampleGroup when given :spec_path => '\\blah\\spec\\controllers\\' (windows format)" do
98 example_group = Spec::Example::ExampleGroupFactory.create_example_group(
99 "name", :spec_path => '\\blah\\spec\\controllers\\blah.rb'
100 ) {}
101 example_group.superclass.should == Spec::Rails::Example::ControllerExampleGroup
102 end
103
104 it "should favor the :type over the :spec_path" do
105 example_group = Spec::Example::ExampleGroupFactory.create_example_group(
106 "name", :spec_path => '/blah/spec/models/blah.rb', :type => :controller
107 ) {}
108 example_group.superclass.should == Spec::Rails::Example::ControllerExampleGroup
109 end
110 end
111 end
112end