Sha256: 6d3e63cb0179d1b4212809957e98608ee505a72184dd23249e76e2a50a7bdeda

Contents?: true

Size: 1.35 KB

Versions: 9

Compression:

Stored size: 1.35 KB

Contents

# rabl_spec_rb
require 'gon'

describe Gon do

  before(:each) do
    Gon::Request.env = {}
  end

  require 'jbuilder'
  require 'gon/jbuilder'
  require 'rabl'
  require 'gon/rabl'

  describe '.get_template_path' do
    context 'template is specified' do

      it 'add the extension if not included in the template name' do
        Gon::Base.send(:get_template_path, { :template => 'spec/test_data/sample'}, 'jbuilder').should eql('spec/test_data/sample.jbuilder')
      end

      it 'return the specified template' do
        Gon::Base.send(:get_template_path, { :template => 'spec/test_data/sample.jbuilder'}, 'jbuilder').should eql('spec/test_data/sample.jbuilder')
      end

    end

    context 'template is not specified' do

      before do
        Gon.clear
        controller.instance_variable_set('@objects', objects)
        controller.action_name = 'show'
      end

      let(:controller) { ActionController::Base.new }
      let(:objects) { [1,2] }

      context 'the action doesn as a template at a different format' do
        it 'return the same template as the action with rabl extension' do
          Gon::Base.send(:get_template_path, {:controller => controller}, 'jbuilder').should eql('app/views/action_controller/base/show.json.jbuilder')
        end
      end

    end
  end

  def request
    @request ||= double 'request', :env => {}
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
gon-4.0.3 spec/gon/templates_spec.rb
gon-4.0.2 spec/gon/templates_spec.rb
gon-4.0.1 spec/gon/templates_spec.rb
gon-4.0.0 spec/gon/templates_spec.rb
gon-3.0.5 spec/gon/templates_spec.rb
gon-3.0.4 spec/gon/templates_spec.rb
gon-3.0.3 spec/gon/templates_spec.rb
gon-3.0.2 spec/gon/templates_spec.rb
gon-3.0.0 spec/gon/templates_spec.rb