Sha256: 11a78b67ba1bdc603a1ba833fbb6f73030d8db817a1be653fc7f17e7d89e18d0

Contents?: true

Size: 697 Bytes

Versions: 1

Compression:

Stored size: 697 Bytes

Contents

require 'spec_helper'
require 'core_ext/active_record/base'

describe ActiveRecord::Base, 'extensions' do
  describe 'floor' do
    subject { ActiveRecord::Base }

    def using(adapter)
      subject.stubs(:configurations).returns('test' => { 'adapter' => adapter})
    end

    it 'returns an sql snippet for postgres' do
      using 'postgresql'
      subject.floor(:number).should == 'floor(number::float)'
    end

    it 'returns an sql snippet for mysql' do
      using 'mysql'
      subject.floor(:number).should == 'floor(number)'
    end

    it 'returns an sql snippet for sqlite3' do
      using 'sqlite3'
      subject.floor(:number).should == 'round(number - 0.5)'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
travis-core-0.0.1 spec/lib/core_ext/active_record_spec.rb