|
73 | 73 | Gon.clear |
74 | 74 | lambda { Gon.all_variables = 123 }.should raise_error |
75 | 75 | lambda { Gon.rabl = 123 }.should raise_error |
76 | | - lambda { Gon.request = 123 }.should raise_error |
77 | 76 | end |
78 | 77 |
|
79 | 78 | describe '.rabl' do |
|
143 | 142 |
|
144 | 143 | end |
145 | 144 |
|
146 | | - require 'jbuilder' |
147 | | - require 'gon/jbuilder' |
| 145 | + require 'jbuilder' |
| 146 | + require 'gon/jbuilder' |
148 | 147 |
|
149 | | - describe '.jbuilder' do |
150 | | - context 'render jbuilder templates' do |
| 148 | + describe '.jbuilder' do |
| 149 | + context 'render jbuilder templates' do |
151 | 150 |
|
152 | | - before do |
153 | | - Gon.clear |
154 | | - controller.instance_variable_set('@objects', objects) |
155 | | - end |
156 | | - |
157 | | - let(:controller) { ActionController::Base.new } |
158 | | - let(:objects) { [1,2] } |
| 151 | + before do |
| 152 | + Gon.clear |
| 153 | + controller.instance_variable_set('@objects', objects) |
| 154 | + end |
159 | 155 |
|
160 | | - it 'render json from jbuilder template' do |
161 | | - Gon.jbuilder 'spec/test_data/sample.json.jbuilder', :controller => controller |
162 | | - Gon.objects.length.should == 2 |
163 | | - end |
| 156 | + let(:controller) { ActionController::Base.new } |
| 157 | + let(:objects) { [1,2] } |
164 | 158 |
|
165 | | - it 'render json from jbuilder template with a partial' do |
166 | | - controller.view_paths << 'spec/test_data' |
167 | | - Gon.jbuilder 'spec/test_data/sample_with_partial.json.jbuilder', :controller => controller |
168 | | - Gon.objects.length.should == 2 |
169 | | - end |
| 159 | + it 'render json from jbuilder template' do |
| 160 | + Gon.jbuilder 'spec/test_data/sample.json.jbuilder', :controller => controller |
| 161 | + Gon.objects.length.should == 2 |
| 162 | + end |
170 | 163 |
|
| 164 | + it 'render json from jbuilder template with a partial' do |
| 165 | + controller.view_paths << 'spec/test_data' |
| 166 | + Gon.jbuilder 'spec/test_data/sample_with_partial.json.jbuilder', :controller => controller |
| 167 | + Gon.objects.length.should == 2 |
171 | 168 | end |
172 | 169 |
|
173 | | - it 'should raise error if you use gon.jbuilder without requiring jbuilder gem' do |
174 | | - Gon.send(:remove_const, :Jbuilder) |
| 170 | + end |
175 | 171 |
|
176 | | - expect { Gon.jbuilder 'some_path' }.to raise_error(NameError) |
177 | | - load 'jbuilder.rb' |
178 | | - load 'gon/jbuilder.rb' |
179 | | - end |
| 172 | + it 'should raise error if you use gon.jbuilder without requiring jbuilder gem' do |
| 173 | + Gon.send(:remove_const, :Jbuilder) |
180 | 174 |
|
| 175 | + expect { Gon.jbuilder 'some_path' }.to raise_error(NameError) |
| 176 | + load 'jbuilder.rb' |
| 177 | + load 'gon/jbuilder.rb' |
181 | 178 | end |
182 | 179 |
|
183 | | - describe '.get_template_path' do |
184 | | - context 'template is specified' do |
| 180 | + end |
185 | 181 |
|
186 | | - it 'add the extension if not included in the template name' do |
187 | | - Gon::Base.send(:get_template_path, { :template => 'spec/test_data/sample'}, 'jbuilder').should eql('spec/test_data/sample.jbuilder') |
188 | | - end |
| 182 | + describe '.get_template_path' do |
| 183 | + context 'template is specified' do |
189 | 184 |
|
190 | | - it 'return the specified template' do |
191 | | - Gon::Base.send(:get_template_path, { :template => 'spec/test_data/sample.jbuilder'}, 'jbuilder').should eql('spec/test_data/sample.jbuilder') |
192 | | - end |
| 185 | + it 'add the extension if not included in the template name' do |
| 186 | + Gon::Base.send(:get_template_path, { :template => 'spec/test_data/sample'}, 'jbuilder').should eql('spec/test_data/sample.jbuilder') |
| 187 | + end |
193 | 188 |
|
| 189 | + it 'return the specified template' do |
| 190 | + Gon::Base.send(:get_template_path, { :template => 'spec/test_data/sample.jbuilder'}, 'jbuilder').should eql('spec/test_data/sample.jbuilder') |
194 | 191 | end |
195 | 192 |
|
196 | | - context 'template is not specified' do |
| 193 | + end |
197 | 194 |
|
198 | | - before do |
199 | | - Gon.clear |
200 | | - controller.instance_variable_set('@objects', objects) |
201 | | - controller.action_name = 'show' |
202 | | - end |
| 195 | + context 'template is not specified' do |
203 | 196 |
|
204 | | - let(:controller) { ActionController::Base.new } |
205 | | - let(:objects) { [1,2] } |
| 197 | + before do |
| 198 | + Gon.clear |
| 199 | + controller.instance_variable_set('@objects', objects) |
| 200 | + controller.action_name = 'show' |
| 201 | + end |
206 | 202 |
|
207 | | - context 'the action doesn as a template at a different format' do |
208 | | - it 'return the same template as the action with rabl extension' do |
209 | | - Gon::Base.send(:get_template_path, {:controller => controller}, 'jbuilder').should eql('app/views/action_controller/base/show.json.jbuilder') |
210 | | - end |
211 | | - end |
| 203 | + let(:controller) { ActionController::Base.new } |
| 204 | + let(:objects) { [1,2] } |
212 | 205 |
|
| 206 | + context 'the action doesn as a template at a different format' do |
| 207 | + it 'return the same template as the action with rabl extension' do |
| 208 | + Gon::Base.send(:get_template_path, {:controller => controller}, 'jbuilder').should eql('app/views/action_controller/base/show.json.jbuilder') |
| 209 | + end |
213 | 210 | end |
| 211 | + |
214 | 212 | end |
| 213 | + end |
215 | 214 |
|
216 | 215 |
|
217 | 216 | def request |
|
0 commit comments