Sha256: 8592c664669cef1b9b5d8a0191c8d5a0082a3536e0008b3affd41550c83bcc5d

Contents?: true

Size: 911 Bytes

Versions: 12

Compression:

Stored size: 911 Bytes

Contents

require 'helper'

describe Arel::Nodes::Extract do
  it "should extract field" do
    table = Arel::Table.new :users
    table[:timestamp].extract('date').to_sql.must_be_like %{
      EXTRACT(DATE FROM "users"."timestamp")
    }
  end

  describe "as" do
    it 'should alias the extract' do
      table = Arel::Table.new :users
      table[:timestamp].extract('date').as('foo').to_sql.must_be_like %{
        EXTRACT(DATE FROM "users"."timestamp") AS foo
      }
    end
  end

  describe 'equality' do
    it 'is equal with equal ivars' do
      table = Arel::Table.new :users
      array = [table[:attr].extract('foo'), table[:attr].extract('foo')]
      assert_equal 1, array.uniq.size
    end

    it 'is not equal with different ivars' do
      table = Arel::Table.new :users
      array = [table[:attr].extract('foo'), table[:attr].extract('bar')]
      assert_equal 2, array.uniq.size
    end
  end
end

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/arel-5.0.1.20140414130214/test/nodes/test_extract.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/arel-5.0.1.20140414130214/test/nodes/test_extract.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/arel-5.0.1.20140414130214/test/nodes/test_extract.rb
arel-6.0.0.beta1 test/nodes/test_extract.rb
arel-5.0.1.20140414130214 test/nodes/test_extract.rb
arel-4.0.2 test/nodes/test_extract.rb
arel-5.0.0 test/nodes/test_extract.rb
arel-4.0.1 test/nodes/test_extract.rb
challah-1.0.0 vendor/bundle/gems/arel-4.0.0/test/nodes/test_extract.rb
arel-4.0.0 test/nodes/test_extract.rb
arel-4.0.0.beta2 test/nodes/test_extract.rb
arel-4.0.0.beta1 test/nodes/test_extract.rb