Sha256: 96a860db1d6f38adf97ea6f3d37d3795eea2cc05abc652bd24945a3e49419cf9

Contents?: true

Size: 1.35 KB

Versions: 2

Compression:

Stored size: 1.35 KB

Contents

require './spec/rails_helper'

if ActionPack::VERSION::MAJOR == 6
  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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
versioncake-4.1.1 spec/integration/view/view_additions_rails6_spec.rb
versioncake-4.1.0 spec/integration/view/view_additions_rails6_spec.rb