spec/gon/jbuilder_spec.rb in gon-4.0.3 vs spec/gon/jbuilder_spec.rb in gon-4.1.0

- old
+ new

@@ -1,17 +1,13 @@ -# rabl_spec_rb -require 'gon' +require 'spec_helper' describe Gon do before(:each) do Gon::Request.env = {} end - require 'jbuilder' - require 'gon/jbuilder' - describe '.jbuilder' do context 'render jbuilder templates' do before do Gon.clear @@ -24,11 +20,29 @@ it 'render json from jbuilder template' do Gon.jbuilder 'spec/test_data/sample.json.jbuilder', :controller => controller Gon.objects.length.should == 2 end - it 'render json from jbuilder template with helpers' do + it 'render json from jbuilder template with locals' do + Gon.jbuilder 'spec/test_data/sample_with_locals.json.jbuilder', :controller => controller, :locals => { :some_local => 1234 } + Gon.some_local.should == 1234 + end + + it 'render json from jbuilder template with locals' do Gon.jbuilder 'spec/test_data/sample_with_helpers.json.jbuilder', :controller => controller + Gon.date.should == 'about 6 hours' + end + + it 'render json from jbuilder template with controller methods' do + pending + controller.instance_eval { + def private_controller_method + puts 'gon test helper works' + end + private :private_controller_method + } + + Gon.jbuilder 'spec/test_data/sample_with_controller_method.json.jbuilder', :controller => controller Gon.date.should == 'about 6 hours' end it 'render json from jbuilder template with a partial' do controller.view_paths << 'spec/test_data'