Sha256: aa3fe967e0f3bfae91fbe29539905e77621a905cac4baa94a9f2b5e6b843325a

Contents?: true

Size: 1.13 KB

Versions: 6

Compression:

Stored size: 1.13 KB

Contents

describe Gon do

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

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

      it 'return the specified template' do
        expect(Gon::EnvFinder.send(:template_path, { :template => 'spec/test_data/sample.jbuilder' }, 'jbuilder')).to 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
          expect(Gon::EnvFinder.send(:template_path, { :controller => controller }, 'jbuilder')).to eql('app/views/action_controller/base/show.json.jbuilder')
        end
      end

    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gon-6.4.0 spec/gon/templates_spec.rb
gon-6.3.2 spec/gon/templates_spec.rb
gon-6.3.1 spec/gon/templates_spec.rb
gon-6.2.1 spec/gon/templates_spec.rb
gon-6.2.0 spec/gon/templates_spec.rb
gon-6.1.0 spec/gon/templates_spec.rb