Sha256: 2e2b3eb69302549ee9cc258e1378baf4a80a5fb004705dbc83e55a0436f4a0f3

Contents?: true

Size: 1.3 KB

Versions: 6

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'

module Draper
  RSpec.describe Configuration do
    it 'yields Draper on configure' do
      Draper.configure { |config| expect(config).to be Draper }
    end

    describe '#default_controller' do
      it 'defaults default_controller to ApplicationController' do
        expect(Draper.default_controller).to be ApplicationController
      end

      it 'allows customizing default_controller through configure' do
        default = Draper.default_controller

        Draper.configure do |config|
          config.default_controller = CustomController
        end

        expect(Draper.default_controller).to be CustomController

        Draper.default_controller = default
      end
    end

    describe '#default_query_methods_strategy' do
      let!(:default) { Draper.default_query_methods_strategy }

      subject { Draper.default_query_methods_strategy }

      context 'when there is no custom strategy' do
        it { is_expected.to eq(:active_record) }
      end

      context 'when using a custom strategy' do
        before do
          Draper.configure do |config|
            config.default_query_methods_strategy = :mongoid
          end
        end

        after { Draper.default_query_methods_strategy = default }

        it { is_expected.to eq(:mongoid) }
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
draper-4.0.4 spec/draper/configuration_spec.rb
draper-4.0.3 spec/draper/configuration_spec.rb
draper-4.0.2 spec/draper/configuration_spec.rb
draper-4.0.1 spec/draper/configuration_spec.rb
draper-4.0.0 spec/draper/configuration_spec.rb
draper-3.1.0 spec/draper/configuration_spec.rb