authorized_rails_scaffolds 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +13 -26
- data/lib/authorized_rails_scaffolds.rb +11 -2
- data/lib/authorized_rails_scaffolds/controller_macros.rb +22 -0
- data/lib/authorized_rails_scaffolds/factory_macros.rb +65 -0
- data/lib/authorized_rails_scaffolds/helper.rb +38 -115
- data/lib/authorized_rails_scaffolds/rails_erb_scaffold_helper.rb +40 -0
- data/lib/authorized_rails_scaffolds/rails_scaffold_controller_helper.rb +20 -0
- data/lib/authorized_rails_scaffolds/resource_macros.rb +81 -0
- data/lib/authorized_rails_scaffolds/route_example_macros.rb +43 -0
- data/lib/authorized_rails_scaffolds/rspec_scaffold_controller_helper.rb +17 -0
- data/lib/authorized_rails_scaffolds/rspec_scaffold_helper.rb +26 -0
- data/lib/authorized_rails_scaffolds/rspec_scaffold_routing_helper.rb +12 -0
- data/lib/authorized_rails_scaffolds/{rspec_scaffold_generator_view_helper.rb → rspec_scaffold_view_helper.rb} +3 -2
- data/lib/authorized_rails_scaffolds/test_var_macros.rb +40 -0
- data/lib/authorized_rails_scaffolds/version.rb +1 -1
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/_form.html.erb +4 -6
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/controller.rb +50 -34
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/edit.html.erb +2 -4
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/index.html.erb +17 -18
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/new.html.erb +2 -4
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/show.html.erb +15 -17
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/controller_spec.rb +126 -101
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/edit_spec.rb +44 -39
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/index_spec.rb +73 -65
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/model_spec.rb +9 -8
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/new_spec.rb +38 -35
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/routing_spec.rb +21 -10
- data/lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/show_spec.rb +37 -20
- data/spec/lib/authorized_rails_scaffolds/rails_erb_scaffold_helper_spec.rb +59 -0
- data/spec/lib/authorized_rails_scaffolds/rails_scaffold_controller_helper_spec.rb +89 -0
- data/spec/lib/authorized_rails_scaffolds/rspec_scaffold_controller_helper_spec.rb +155 -0
- data/spec/lib/authorized_rails_scaffolds/{rspec_scaffold_generator_helper_spec.rb → rspec_scaffold_routing_helper_spec.rb} +57 -50
- data/spec/lib/authorized_rails_scaffolds/rspec_scaffold_view_helper_spec.rb +86 -0
- data/spec/spec_helper.rb +5 -2
- data/spec/support/rails_erb_scaffold_helper_macros.rb +15 -0
- data/spec/support/rails_scaffold_controller_helper_macros.rb +15 -0
- data/spec/support/{rspec_scaffold_generator_helper_macros.rb → rspec_scaffold_controller_helper_macros.rb} +2 -2
- data/spec/support/rspec_scaffold_routing_helper_macros.rb +15 -0
- data/spec/support/rspec_scaffold_view_helper_macros.rb +15 -0
- metadata +66 -28
- data/lib/authorized_rails_scaffolds/rspec_scaffold_generator_helper.rb +0 -82
@@ -0,0 +1,155 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe AuthorizedRailsScaffolds::RSpecScaffoldControllerHelper do
|
4
|
+
include RSpecScaffoldControllerHelperMacros
|
5
|
+
|
6
|
+
describe '#controller_class_name' do
|
7
|
+
context 'with no parent modules' do
|
8
|
+
it 'returns the pluralized class_name with Controller appended' do
|
9
|
+
subject = build_controller_spec_helper :class_name => 'FooBar'
|
10
|
+
subject.controller_class_name.should eq('FooBarsController')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
context 'with a parent modules' do
|
14
|
+
it 'returns the pluralized controller class name nested within the parent module' do
|
15
|
+
subject = build_controller_spec_helper :class_name => 'Example::FooBar'
|
16
|
+
subject.controller_class_name.should eq('Example::FooBarsController')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
context 'with multiple parent modules' do
|
20
|
+
it 'returns the pluralized a controller class name nested within the parent modules' do
|
21
|
+
subject = build_controller_spec_helper :class_name => 'Example::V1::FooBar'
|
22
|
+
subject.controller_class_name.should eq('Example::V1::FooBarsController')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
context 'with generated controller_class_name value' do
|
26
|
+
it 'returns the generated controller_class_name with Controller appended' do
|
27
|
+
subject = build_controller_spec_helper :controller_class_name => 'Example::V1::FooBars'
|
28
|
+
subject.controller_class_name.should eq('Example::V1::FooBarsController')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
context 'with a parent module' do
|
32
|
+
before(:each) do
|
33
|
+
AuthorizedRailsScaffolds.configure do |config|
|
34
|
+
config.parent_models = ['Parent']
|
35
|
+
end
|
36
|
+
end
|
37
|
+
it 'ignores the parent module value' do
|
38
|
+
subject = build_controller_spec_helper :class_name => 'FooBar'
|
39
|
+
subject.controller_class_name.should eq('FooBarsController')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#create_resource_from_factory' do
|
45
|
+
context 'with no parent_models' do
|
46
|
+
it 'returns a code fragment that creates the model' do
|
47
|
+
subject = build_controller_spec_helper :var_name => 'foo_bar'
|
48
|
+
subject.create_resource_from_factory.should eq('FactoryGirl.create(:foo_bar)')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
context 'with a parent model' do
|
52
|
+
before(:each) do
|
53
|
+
AuthorizedRailsScaffolds.configure do |config|
|
54
|
+
config.parent_models = ['Parent']
|
55
|
+
end
|
56
|
+
end
|
57
|
+
it 'returns a code fragment including the parent reference' do
|
58
|
+
subject = build_controller_spec_helper :var_name => 'foo_bar'
|
59
|
+
subject.create_resource_from_factory.should eq('FactoryGirl.create(:foo_bar, :parent => @parent)')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
context 'with multiple parent models' do
|
63
|
+
before(:each) do
|
64
|
+
AuthorizedRailsScaffolds.configure do |config|
|
65
|
+
config.parent_models = ['Grandparent', 'Parent']
|
66
|
+
end
|
67
|
+
end
|
68
|
+
it 'returns a code fragment including the last parent fragment' do
|
69
|
+
subject = build_controller_spec_helper :var_name => 'foo_bar'
|
70
|
+
subject.create_resource_from_factory.should eq('FactoryGirl.create(:foo_bar, :parent => @parent)')
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#create_parent_resource_from_factory' do
|
76
|
+
context 'with a parent model' do
|
77
|
+
before(:each) do
|
78
|
+
AuthorizedRailsScaffolds.configure do |config|
|
79
|
+
config.parent_models = ['Parent']
|
80
|
+
end
|
81
|
+
end
|
82
|
+
it 'returns a code fragment with no parent references' do
|
83
|
+
subject = build_controller_spec_helper
|
84
|
+
subject.create_parent_resource_from_factory('parent').should eq('FactoryGirl.create(:parent)')
|
85
|
+
end
|
86
|
+
end
|
87
|
+
context 'with multiple parent models' do
|
88
|
+
before(:each) do
|
89
|
+
AuthorizedRailsScaffolds.configure do |config|
|
90
|
+
config.parent_models = ['Grandparent', 'Parent']
|
91
|
+
end
|
92
|
+
end
|
93
|
+
it 'returns last parent fragment with a references to the grandparent' do
|
94
|
+
subject = build_controller_spec_helper
|
95
|
+
subject.create_parent_resource_from_factory('parent').should eq('FactoryGirl.create(:parent, :grandparent => @grandparent)')
|
96
|
+
end
|
97
|
+
it 'returns the grandparent element with no references to other classes' do
|
98
|
+
subject = build_controller_spec_helper
|
99
|
+
subject.create_parent_resource_from_factory('grandparent').should eq('FactoryGirl.create(:grandparent)')
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe '#parent_model_tables' do
|
105
|
+
context 'with no parent_models' do
|
106
|
+
it 'returns an empty array' do
|
107
|
+
subject = build_controller_spec_helper
|
108
|
+
subject.parent_model_tables.should eq([])
|
109
|
+
end
|
110
|
+
end
|
111
|
+
context 'with a parent model' do
|
112
|
+
before(:each) do
|
113
|
+
AuthorizedRailsScaffolds.configure do |config|
|
114
|
+
config.parent_models = ['Parent']
|
115
|
+
end
|
116
|
+
end
|
117
|
+
it 'returns an array containing the models table name' do
|
118
|
+
subject = build_controller_spec_helper
|
119
|
+
subject.parent_model_tables.should eq(['parent'])
|
120
|
+
end
|
121
|
+
end
|
122
|
+
context 'with multiple parent models' do
|
123
|
+
before(:each) do
|
124
|
+
AuthorizedRailsScaffolds.configure do |config|
|
125
|
+
config.parent_models = ['Grandparent', 'Parent']
|
126
|
+
end
|
127
|
+
end
|
128
|
+
it 'returns an array containing all model table names' do
|
129
|
+
subject = build_controller_spec_helper
|
130
|
+
subject.parent_model_tables.should eq(['grandparent', 'parent'])
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe '#resource_var' do
|
136
|
+
it 'returns var_name preceeded by an @' do
|
137
|
+
subject = build_controller_spec_helper :var_name => 'foo_bar'
|
138
|
+
subject.resource_var.should eq('@foo_bar')
|
139
|
+
end
|
140
|
+
context 'with a parent module' do
|
141
|
+
it 'falls back to using class_name if var_name is not present' do
|
142
|
+
subject = build_controller_spec_helper :var_name => nil, :class_name => 'Example::FooBar'
|
143
|
+
subject.resource_var.should eq('@foo_bar')
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
describe '#resource_test_var' do
|
149
|
+
it 'returns var_name preceeded by an @' do
|
150
|
+
subject = build_controller_spec_helper :var_name => 'foo_bar'
|
151
|
+
subject.resource_test_var.should eq('@foo_bar')
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
end
|
@@ -1,44 +1,57 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe AuthorizedRailsScaffolds::
|
3
|
+
describe AuthorizedRailsScaffolds::RSpecScaffoldRoutingHelper do
|
4
|
+
include RSpecScaffoldRoutingHelperMacros
|
4
5
|
|
5
|
-
describe '#
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
describe '#controller_class_name' do
|
7
|
+
context 'with no parent modules' do
|
8
|
+
it 'returns the pluralized class_name with Controller appended' do
|
9
|
+
subject = build_routing_spec_helper :class_name => 'FooBar'
|
10
|
+
subject.controller_class_name.should eq('FooBarsController')
|
11
|
+
end
|
9
12
|
end
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
+
context 'with a parent modules' do
|
14
|
+
it 'returns the pluralized controller class name nested within the parent module' do
|
15
|
+
subject = build_routing_spec_helper :class_name => 'Example::FooBar'
|
16
|
+
subject.controller_class_name.should eq('Example::FooBarsController')
|
17
|
+
end
|
13
18
|
end
|
14
|
-
|
15
|
-
|
16
|
-
|
19
|
+
context 'with multiple parent modules' do
|
20
|
+
it 'returns the pluralized controller class name nested within the parent modules' do
|
21
|
+
subject = build_routing_spec_helper :class_name => 'Example::V1::FooBar'
|
22
|
+
subject.controller_class_name.should eq('Example::V1::FooBarsController')
|
23
|
+
end
|
17
24
|
end
|
18
|
-
context 'with
|
25
|
+
context 'with generated controller_class_name value' do
|
26
|
+
it 'returns the generated controller_class_name with Controller appended' do
|
27
|
+
subject = build_routing_spec_helper :controller_class_name => 'Example::V1::FooBars'
|
28
|
+
subject.controller_class_name.should eq('Example::V1::FooBarsController')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
context 'with a parent module' do
|
19
32
|
before(:each) do
|
20
33
|
AuthorizedRailsScaffolds.configure do |config|
|
21
34
|
config.parent_models = ['Parent']
|
22
35
|
end
|
23
36
|
end
|
24
|
-
it 'ignores the
|
25
|
-
subject =
|
26
|
-
subject.
|
37
|
+
it 'ignores the parent module value' do
|
38
|
+
subject = build_routing_spec_helper :class_name => 'FooBar'
|
39
|
+
subject.controller_class_name.should eq('FooBarsController')
|
27
40
|
end
|
28
41
|
end
|
29
42
|
end
|
30
43
|
|
31
44
|
describe '#example_controller_path' do
|
32
45
|
it 'underscores the class_name value' do
|
33
|
-
subject =
|
46
|
+
subject = build_routing_spec_helper :class_name => 'FooBar'
|
34
47
|
subject.example_controller_path.should eq('/foo_bars')
|
35
48
|
end
|
36
49
|
it 'adds parent_models to the file path' do
|
37
|
-
subject =
|
50
|
+
subject = build_routing_spec_helper :class_name => 'Example::FooBar'
|
38
51
|
subject.example_controller_path.should eq('/example/foo_bars')
|
39
52
|
end
|
40
53
|
it 'adds multiple parent_models to the file path' do
|
41
|
-
subject =
|
54
|
+
subject = build_routing_spec_helper :class_name => 'Example::V1::FooBar'
|
42
55
|
subject.example_controller_path.should eq('/example/v1/foo_bars')
|
43
56
|
end
|
44
57
|
context 'with a parent model' do
|
@@ -48,15 +61,15 @@ describe AuthorizedRailsScaffolds::RSpecScaffoldGeneratorHelper do
|
|
48
61
|
end
|
49
62
|
end
|
50
63
|
it 'adds the parent model before the class name' do
|
51
|
-
subject =
|
64
|
+
subject = build_routing_spec_helper :class_name => 'FooBar'
|
52
65
|
subject.example_controller_path.should eq('/parents/2/foo_bars')
|
53
66
|
end
|
54
67
|
it 'adds the parent model after the parent module' do
|
55
|
-
subject =
|
68
|
+
subject = build_routing_spec_helper :class_name => 'Example::FooBar'
|
56
69
|
subject.example_controller_path.should eq('/example/parents/2/foo_bars')
|
57
70
|
end
|
58
71
|
it 'adds the parent model after multiple parent module' do
|
59
|
-
subject =
|
72
|
+
subject = build_routing_spec_helper :class_name => 'Example::V1::FooBar'
|
60
73
|
subject.example_controller_path.should eq('/example/v1/parents/2/foo_bars')
|
61
74
|
end
|
62
75
|
end
|
@@ -66,11 +79,11 @@ describe AuthorizedRailsScaffolds::RSpecScaffoldGeneratorHelper do
|
|
66
79
|
config.parent_models = ['Grandparent', 'Parent']
|
67
80
|
end
|
68
81
|
it 'adds the parent models before the class name' do
|
69
|
-
subject =
|
82
|
+
subject = build_routing_spec_helper :class_name => 'FooBar'
|
70
83
|
subject.example_controller_path.should eq('/grandparents/2/parents/3/foo_bars')
|
71
84
|
end
|
72
85
|
it 'adds the parent models after the parent module' do
|
73
|
-
subject =
|
86
|
+
subject = build_routing_spec_helper :class_name => 'Example::FooBar'
|
74
87
|
subject.example_controller_path.should eq('/example/grandparents/2/parents/3/foo_bars')
|
75
88
|
end
|
76
89
|
end
|
@@ -80,11 +93,11 @@ describe AuthorizedRailsScaffolds::RSpecScaffoldGeneratorHelper do
|
|
80
93
|
describe '#example_controller_path_extra_params' do
|
81
94
|
context 'with no parent models' do
|
82
95
|
it 'returns an empty string with no parent module' do
|
83
|
-
subject =
|
96
|
+
subject = build_routing_spec_helper :class_name => 'FooBar'
|
84
97
|
subject.example_controller_path_extra_params.should eq('')
|
85
98
|
end
|
86
99
|
it 'returns an empty string with a parent module' do
|
87
|
-
subject =
|
100
|
+
subject = build_routing_spec_helper :class_name => 'Example::FooBar'
|
88
101
|
subject.example_controller_path_extra_params.should eq('')
|
89
102
|
end
|
90
103
|
end
|
@@ -95,8 +108,8 @@ describe AuthorizedRailsScaffolds::RSpecScaffoldGeneratorHelper do
|
|
95
108
|
end
|
96
109
|
end
|
97
110
|
it 'adds the parent model with a value assigned to it' do
|
98
|
-
subject =
|
99
|
-
subject.example_controller_path_extra_params.should eq(', :parent_id => 2')
|
111
|
+
subject = build_routing_spec_helper :class_name => 'FooBar'
|
112
|
+
subject.example_controller_path_extra_params.should eq(', :parent_id => "2"')
|
100
113
|
end
|
101
114
|
end
|
102
115
|
context 'with multiple parent models' do
|
@@ -106,18 +119,24 @@ describe AuthorizedRailsScaffolds::RSpecScaffoldGeneratorHelper do
|
|
106
119
|
end
|
107
120
|
end
|
108
121
|
it 'adds the parent models with their values' do
|
109
|
-
subject =
|
110
|
-
subject.example_controller_path_extra_params.should eq(', :grandparent_id => 2, :parent_id => 3')
|
122
|
+
subject = build_routing_spec_helper :class_name => 'FooBar'
|
123
|
+
subject.example_controller_path_extra_params.should eq(', :grandparent_id => "2", :parent_id => "3"')
|
111
124
|
end
|
112
125
|
end
|
113
126
|
end
|
114
127
|
|
115
|
-
describe '#
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
128
|
+
describe '#resource_directory' do
|
129
|
+
it 'underscores the class_name value' do
|
130
|
+
subject = build_routing_spec_helper :class_name => 'FooBar'
|
131
|
+
subject.resource_directory.should eq('foo_bars')
|
132
|
+
end
|
133
|
+
it 'adds parent_models to the file path' do
|
134
|
+
subject = build_routing_spec_helper :class_name => 'Example::FooBar'
|
135
|
+
subject.resource_directory.should eq('example/foo_bars')
|
136
|
+
end
|
137
|
+
it 'adds multiple parent_models to the file path' do
|
138
|
+
subject = build_routing_spec_helper :class_name => 'Example::V1::FooBar'
|
139
|
+
subject.resource_directory.should eq('example/v1/foo_bars')
|
121
140
|
end
|
122
141
|
context 'with a parent model' do
|
123
142
|
before(:each) do
|
@@ -125,23 +144,11 @@ describe AuthorizedRailsScaffolds::RSpecScaffoldGeneratorHelper do
|
|
125
144
|
config.parent_models = ['Parent']
|
126
145
|
end
|
127
146
|
end
|
128
|
-
it '
|
129
|
-
subject =
|
130
|
-
subject.
|
131
|
-
end
|
132
|
-
end
|
133
|
-
context 'with multiple parent models' do
|
134
|
-
before(:each) do
|
135
|
-
AuthorizedRailsScaffolds.configure do |config|
|
136
|
-
config.parent_models = ['Grandparent', 'Parent']
|
137
|
-
end
|
138
|
-
end
|
139
|
-
it 'returns an array containing all model table names' do
|
140
|
-
subject = build_controller_spec_helper
|
141
|
-
subject.parent_model_tables.should eq(['grandparent', 'parent'])
|
147
|
+
it 'ignores the parent_model value' do
|
148
|
+
subject = build_routing_spec_helper :class_name => 'FooBar'
|
149
|
+
subject.resource_directory.should eq('foo_bars')
|
142
150
|
end
|
143
151
|
end
|
144
152
|
end
|
145
153
|
|
146
|
-
|
147
154
|
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe AuthorizedRailsScaffolds::RSpecScaffoldViewHelper do
|
4
|
+
include RSpecScaffoldViewHelperMacros
|
5
|
+
pending
|
6
|
+
|
7
|
+
describe '#parent_model_tables' do
|
8
|
+
context 'with no parent_models' do
|
9
|
+
it 'returns an empty array' do
|
10
|
+
subject = build_view_spec_helper
|
11
|
+
subject.parent_model_tables.should eq([])
|
12
|
+
end
|
13
|
+
end
|
14
|
+
context 'with a parent model' do
|
15
|
+
before(:each) do
|
16
|
+
AuthorizedRailsScaffolds.configure do |config|
|
17
|
+
config.parent_models = ['Parent']
|
18
|
+
end
|
19
|
+
end
|
20
|
+
it 'returns an array containing the models table name' do
|
21
|
+
subject = build_view_spec_helper
|
22
|
+
subject.parent_model_tables.should eq(['parent'])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
context 'with multiple parent models' do
|
26
|
+
before(:each) do
|
27
|
+
AuthorizedRailsScaffolds.configure do |config|
|
28
|
+
config.parent_models = ['Grandparent', 'Parent']
|
29
|
+
end
|
30
|
+
end
|
31
|
+
it 'returns an array containing all model table names' do
|
32
|
+
subject = build_view_spec_helper
|
33
|
+
subject.parent_model_tables.should eq(['grandparent', 'parent'])
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#resource_directory' do
|
39
|
+
it 'underscores the class_name value' do
|
40
|
+
subject = build_view_spec_helper :class_name => 'FooBar'
|
41
|
+
subject.resource_directory.should eq('foo_bars')
|
42
|
+
end
|
43
|
+
it 'adds parent_models to the file path' do
|
44
|
+
subject = build_view_spec_helper :class_name => 'Example::FooBar'
|
45
|
+
subject.resource_directory.should eq('example/foo_bars')
|
46
|
+
end
|
47
|
+
it 'adds multiple parent_models to the file path' do
|
48
|
+
subject = build_view_spec_helper :class_name => 'Example::V1::FooBar'
|
49
|
+
subject.resource_directory.should eq('example/v1/foo_bars')
|
50
|
+
end
|
51
|
+
context 'with a parent model' do
|
52
|
+
before(:each) do
|
53
|
+
AuthorizedRailsScaffolds.configure do |config|
|
54
|
+
config.parent_models = ['Parent']
|
55
|
+
end
|
56
|
+
end
|
57
|
+
it 'ignores the parent_model value' do
|
58
|
+
subject = build_view_spec_helper :class_name => 'FooBar'
|
59
|
+
subject.resource_directory.should eq('foo_bars')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '#resource_test_sym' do
|
65
|
+
it 'returns var_name preceeded by an :' do
|
66
|
+
subject = build_view_spec_helper :var_name => 'foo_bar'
|
67
|
+
subject.resource_test_sym.should eq(':foo_bar')
|
68
|
+
end
|
69
|
+
it 'appends a number if included' do
|
70
|
+
subject = build_view_spec_helper :var_name => 'foo_bar'
|
71
|
+
subject.resource_test_sym(2).should eq(':foo_bar_2')
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#resource_test_var' do
|
76
|
+
it 'returns var_name preceeded by an @' do
|
77
|
+
subject = build_view_spec_helper :var_name => 'foo_bar'
|
78
|
+
subject.resource_test_var.should eq('@foo_bar')
|
79
|
+
end
|
80
|
+
it 'appends a number if included' do
|
81
|
+
subject = build_view_spec_helper :var_name => 'foo_bar'
|
82
|
+
subject.resource_test_var(2).should eq('@foo_bar_2')
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,10 +4,13 @@ Bundler.require
|
|
4
4
|
require 'rails'
|
5
5
|
|
6
6
|
require 'authorized_rails_scaffolds'
|
7
|
-
require 'support/
|
7
|
+
require 'support/rails_erb_scaffold_helper_macros'
|
8
|
+
require 'support/rails_scaffold_controller_helper_macros'
|
9
|
+
require 'support/rspec_scaffold_controller_helper_macros'
|
10
|
+
require 'support/rspec_scaffold_routing_helper_macros'
|
11
|
+
require 'support/rspec_scaffold_view_helper_macros'
|
8
12
|
|
9
13
|
RSpec.configure do |config|
|
10
|
-
config.include RSpecScaffoldGeneratorHelperMacros
|
11
14
|
# some (optional) config here
|
12
15
|
|
13
16
|
config.after(:each) do
|