Sha256: cff71b8135289e8e318519768999251703e9695dc6aff5dd9ab76d404b43d821

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

require './spec/rails_helper'

describe ActionView::PathResolver do
  let(:resolver) { ActionView::PathResolver.new }

  context '#extract_handler_and_format' do
    subject(:template_format) do
      _, format = resolver.extract_handler_and_format("application.#{template_extension}", nil)
      format.to_s
    end

    context 'when only handler and format are present' do
      let(:template_extension) { 'html.erb' }

      it { expect(template_format).to eq 'text/html' }
    end

    context 'when handler, format and version are present' do
      let(:template_extension) { 'json.v1.jbuilder' }

      it { expect(template_format).to eq 'application/json' }
    end

    context 'when handler, format and locale are present' do
      let(:template_extension) { 'en.json.jbuilder' }

      it { expect(template_format).to eq 'application/json' }
    end

    context 'when handler, format, locale and version are present' do
      let(:template_extension) { 'en.json.v1.jbuilder' }

      it { expect(template_format).to eq 'application/json' }
    end

    context 'when handler, format, variant and version are present' do
      let(:template_extension) { 'application.json+tablet.v1.jbuilder' }

      it { expect(template_format).to eq 'application/json' }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
versioncake-4.0.2 spec/integration/view/view_additions_spec.rb
versioncake-4.0.1 spec/integration/view/view_additions_spec.rb
versioncake-4.0.0 spec/integration/view/view_additions_spec.rb