Sha256: d6c085f7fb16c809f4d10ec58b40b13a5c875debec58399e5c2f0728270549b1

Contents?: true

Size: 985 Bytes

Versions: 1

Compression:

Stored size: 985 Bytes

Contents

require "rails_helper"

module Sortability
  module ActiveRecord
    module ConnectionAdapters
      RSpec.describe TableDefinition do
        let(:table_definition) { ::ActiveRecord::ConnectionAdapters::TableDefinition.new :test }

        context 'without :on and :null' do
          let(:options) { { something: :else } }

          it '#sortable calls the #integer method, adding defaults' do
            expect(table_definition).to(
              receive(:integer).with(:sort_position, options.merge(null: false))
            )
            table_definition.sortable options
          end
        end

        context 'with :on and :null' do
          let(:options) { { something: :else, on: :pos, null: true } }

          it '#sortable calls the #integer method with the given options' do
            expect(table_definition).to receive(:integer).with(:pos, options.except(:on))
            table_definition.sortable options
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sortability-1.0.0 spec/lib/sortability/active_record/connection_adapters/table_definition_spec.rb