aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/arel/attributes
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2018-02-24 17:15:50 +1030
committerMatthew Draper <matthew@trebex.net>2018-02-24 17:16:13 +1030
commit4c0a3d48804a363c7e9272519665a21f601b5248 (patch)
tree6b1f6e28f85cfd69a0ce534856ef939c7079d5cf /activerecord/test/cases/arel/attributes
parent17ca17072dcdff11b3702a6b45f2fb0c8f8fe9a4 (diff)
downloadrails-4c0a3d48804a363c7e9272519665a21f601b5248.tar.gz
rails-4c0a3d48804a363c7e9272519665a21f601b5248.tar.bz2
rails-4c0a3d48804a363c7e9272519665a21f601b5248.zip
Arel: rubocop -a
Diffstat (limited to 'activerecord/test/cases/arel/attributes')
-rw-r--r--activerecord/test/cases/arel/attributes/attribute_test.rb445
1 files changed, 223 insertions, 222 deletions
diff --git a/activerecord/test/cases/arel/attributes/attribute_test.rb b/activerecord/test/cases/arel/attributes/attribute_test.rb
index 802d6e743f..52573021a5 100644
--- a/activerecord/test/cases/arel/attributes/attribute_test.rb
+++ b/activerecord/test/cases/arel/attributes/attribute_test.rb
@@ -1,17 +1,18 @@
# frozen_string_literal: true
-require_relative '../helper'
-require 'ostruct'
+
+require_relative "../helper"
+require "ostruct"
module Arel
module Attributes
class AttributeTest < Arel::Spec
- describe '#not_eq' do
- it 'should create a NotEqual node' do
+ describe "#not_eq" do
+ it "should create a NotEqual node" do
relation = Table.new(:users)
relation[:id].not_eq(10).must_be_kind_of Nodes::NotEqual
end
- it 'should generate != in sql' do
+ it "should generate != in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
mgr.where relation[:id].not_eq(10)
@@ -20,7 +21,7 @@ module Arel
}
end
- it 'should handle nil' do
+ it "should handle nil" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
mgr.where relation[:id].not_eq(nil)
@@ -30,45 +31,45 @@ module Arel
end
end
- describe '#not_eq_any' do
- it 'should create a Grouping node' do
+ describe "#not_eq_any" do
+ it "should create a Grouping node" do
relation = Table.new(:users)
- relation[:id].not_eq_any([1,2]).must_be_kind_of Nodes::Grouping
+ relation[:id].not_eq_any([1, 2]).must_be_kind_of Nodes::Grouping
end
- it 'should generate ORs in sql' do
+ it "should generate ORs in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:id].not_eq_any([1,2])
+ mgr.where relation[:id].not_eq_any([1, 2])
mgr.to_sql.must_be_like %{
SELECT "users"."id" FROM "users" WHERE ("users"."id" != 1 OR "users"."id" != 2)
}
end
end
- describe '#not_eq_all' do
- it 'should create a Grouping node' do
+ describe "#not_eq_all" do
+ it "should create a Grouping node" do
relation = Table.new(:users)
- relation[:id].not_eq_all([1,2]).must_be_kind_of Nodes::Grouping
+ relation[:id].not_eq_all([1, 2]).must_be_kind_of Nodes::Grouping
end
- it 'should generate ANDs in sql' do
+ it "should generate ANDs in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:id].not_eq_all([1,2])
+ mgr.where relation[:id].not_eq_all([1, 2])
mgr.to_sql.must_be_like %{
SELECT "users"."id" FROM "users" WHERE ("users"."id" != 1 AND "users"."id" != 2)
}
end
end
- describe '#gt' do
- it 'should create a GreaterThan node' do
+ describe "#gt" do
+ it "should create a GreaterThan node" do
relation = Table.new(:users)
relation[:id].gt(10).must_be_kind_of Nodes::GreaterThan
end
- it 'should generate > in sql' do
+ it "should generate > in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
mgr.where relation[:id].gt(10)
@@ -77,7 +78,7 @@ module Arel
}
end
- it 'should handle comparing with a subquery' do
+ it "should handle comparing with a subquery" do
users = Table.new(:users)
avg = users.project(users[:karma].average)
@@ -88,10 +89,10 @@ module Arel
}
end
- it 'should accept various data types.' do
+ it "should accept various data types." do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:name].gt('fake_name')
+ mgr.where relation[:name].gt("fake_name")
mgr.to_sql.must_match %{"users"."name" > 'fake_name'}
current_time = ::Time.now
@@ -100,45 +101,45 @@ module Arel
end
end
- describe '#gt_any' do
- it 'should create a Grouping node' do
+ describe "#gt_any" do
+ it "should create a Grouping node" do
relation = Table.new(:users)
- relation[:id].gt_any([1,2]).must_be_kind_of Nodes::Grouping
+ relation[:id].gt_any([1, 2]).must_be_kind_of Nodes::Grouping
end
- it 'should generate ORs in sql' do
+ it "should generate ORs in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:id].gt_any([1,2])
+ mgr.where relation[:id].gt_any([1, 2])
mgr.to_sql.must_be_like %{
SELECT "users"."id" FROM "users" WHERE ("users"."id" > 1 OR "users"."id" > 2)
}
end
end
- describe '#gt_all' do
- it 'should create a Grouping node' do
+ describe "#gt_all" do
+ it "should create a Grouping node" do
relation = Table.new(:users)
- relation[:id].gt_all([1,2]).must_be_kind_of Nodes::Grouping
+ relation[:id].gt_all([1, 2]).must_be_kind_of Nodes::Grouping
end
- it 'should generate ANDs in sql' do
+ it "should generate ANDs in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:id].gt_all([1,2])
+ mgr.where relation[:id].gt_all([1, 2])
mgr.to_sql.must_be_like %{
SELECT "users"."id" FROM "users" WHERE ("users"."id" > 1 AND "users"."id" > 2)
}
end
end
- describe '#gteq' do
- it 'should create a GreaterThanOrEqual node' do
+ describe "#gteq" do
+ it "should create a GreaterThanOrEqual node" do
relation = Table.new(:users)
relation[:id].gteq(10).must_be_kind_of Nodes::GreaterThanOrEqual
end
- it 'should generate >= in sql' do
+ it "should generate >= in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
mgr.where relation[:id].gteq(10)
@@ -147,10 +148,10 @@ module Arel
}
end
- it 'should accept various data types.' do
+ it "should accept various data types." do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:name].gteq('fake_name')
+ mgr.where relation[:name].gteq("fake_name")
mgr.to_sql.must_match %{"users"."name" >= 'fake_name'}
current_time = ::Time.now
@@ -159,45 +160,45 @@ module Arel
end
end
- describe '#gteq_any' do
- it 'should create a Grouping node' do
+ describe "#gteq_any" do
+ it "should create a Grouping node" do
relation = Table.new(:users)
- relation[:id].gteq_any([1,2]).must_be_kind_of Nodes::Grouping
+ relation[:id].gteq_any([1, 2]).must_be_kind_of Nodes::Grouping
end
- it 'should generate ORs in sql' do
+ it "should generate ORs in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:id].gteq_any([1,2])
+ mgr.where relation[:id].gteq_any([1, 2])
mgr.to_sql.must_be_like %{
SELECT "users"."id" FROM "users" WHERE ("users"."id" >= 1 OR "users"."id" >= 2)
}
end
end
- describe '#gteq_all' do
- it 'should create a Grouping node' do
+ describe "#gteq_all" do
+ it "should create a Grouping node" do
relation = Table.new(:users)
- relation[:id].gteq_all([1,2]).must_be_kind_of Nodes::Grouping
+ relation[:id].gteq_all([1, 2]).must_be_kind_of Nodes::Grouping
end
- it 'should generate ANDs in sql' do
+ it "should generate ANDs in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:id].gteq_all([1,2])
+ mgr.where relation[:id].gteq_all([1, 2])
mgr.to_sql.must_be_like %{
SELECT "users"."id" FROM "users" WHERE ("users"."id" >= 1 AND "users"."id" >= 2)
}
end
end
- describe '#lt' do
- it 'should create a LessThan node' do
+ describe "#lt" do
+ it "should create a LessThan node" do
relation = Table.new(:users)
relation[:id].lt(10).must_be_kind_of Nodes::LessThan
end
- it 'should generate < in sql' do
+ it "should generate < in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
mgr.where relation[:id].lt(10)
@@ -206,10 +207,10 @@ module Arel
}
end
- it 'should accept various data types.' do
+ it "should accept various data types." do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:name].lt('fake_name')
+ mgr.where relation[:name].lt("fake_name")
mgr.to_sql.must_match %{"users"."name" < 'fake_name'}
current_time = ::Time.now
@@ -218,45 +219,45 @@ module Arel
end
end
- describe '#lt_any' do
- it 'should create a Grouping node' do
+ describe "#lt_any" do
+ it "should create a Grouping node" do
relation = Table.new(:users)
- relation[:id].lt_any([1,2]).must_be_kind_of Nodes::Grouping
+ relation[:id].lt_any([1, 2]).must_be_kind_of Nodes::Grouping
end
- it 'should generate ORs in sql' do
+ it "should generate ORs in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:id].lt_any([1,2])
+ mgr.where relation[:id].lt_any([1, 2])
mgr.to_sql.must_be_like %{
SELECT "users"."id" FROM "users" WHERE ("users"."id" < 1 OR "users"."id" < 2)
}
end
end
- describe '#lt_all' do
- it 'should create a Grouping node' do
+ describe "#lt_all" do
+ it "should create a Grouping node" do
relation = Table.new(:users)
- relation[:id].lt_all([1,2]).must_be_kind_of Nodes::Grouping
+ relation[:id].lt_all([1, 2]).must_be_kind_of Nodes::Grouping
end
- it 'should generate ANDs in sql' do
+ it "should generate ANDs in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:id].lt_all([1,2])
+ mgr.where relation[:id].lt_all([1, 2])
mgr.to_sql.must_be_like %{
SELECT "users"."id" FROM "users" WHERE ("users"."id" < 1 AND "users"."id" < 2)
}
end
end
- describe '#lteq' do
- it 'should create a LessThanOrEqual node' do
+ describe "#lteq" do
+ it "should create a LessThanOrEqual node" do
relation = Table.new(:users)
relation[:id].lteq(10).must_be_kind_of Nodes::LessThanOrEqual
end
- it 'should generate <= in sql' do
+ it "should generate <= in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
mgr.where relation[:id].lteq(10)
@@ -265,10 +266,10 @@ module Arel
}
end
- it 'should accept various data types.' do
+ it "should accept various data types." do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:name].lteq('fake_name')
+ mgr.where relation[:name].lteq("fake_name")
mgr.to_sql.must_match %{"users"."name" <= 'fake_name'}
current_time = ::Time.now
@@ -277,45 +278,45 @@ module Arel
end
end
- describe '#lteq_any' do
- it 'should create a Grouping node' do
+ describe "#lteq_any" do
+ it "should create a Grouping node" do
relation = Table.new(:users)
- relation[:id].lteq_any([1,2]).must_be_kind_of Nodes::Grouping
+ relation[:id].lteq_any([1, 2]).must_be_kind_of Nodes::Grouping
end
- it 'should generate ORs in sql' do
+ it "should generate ORs in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:id].lteq_any([1,2])
+ mgr.where relation[:id].lteq_any([1, 2])
mgr.to_sql.must_be_like %{
SELECT "users"."id" FROM "users" WHERE ("users"."id" <= 1 OR "users"."id" <= 2)
}
end
end
- describe '#lteq_all' do
- it 'should create a Grouping node' do
+ describe "#lteq_all" do
+ it "should create a Grouping node" do
relation = Table.new(:users)
- relation[:id].lteq_all([1,2]).must_be_kind_of Nodes::Grouping
+ relation[:id].lteq_all([1, 2]).must_be_kind_of Nodes::Grouping
end
- it 'should generate ANDs in sql' do
+ it "should generate ANDs in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:id].lteq_all([1,2])
+ mgr.where relation[:id].lteq_all([1, 2])
mgr.to_sql.must_be_like %{
SELECT "users"."id" FROM "users" WHERE ("users"."id" <= 1 AND "users"."id" <= 2)
}
end
end
- describe '#average' do
- it 'should create a AVG node' do
+ describe "#average" do
+ it "should create a AVG node" do
relation = Table.new(:users)
relation[:id].average.must_be_kind_of Nodes::Avg
end
- it 'should generate the proper SQL' do
+ it "should generate the proper SQL" do
relation = Table.new(:users)
mgr = relation.project relation[:id].average
mgr.to_sql.must_be_like %{
@@ -325,13 +326,13 @@ module Arel
end
end
- describe '#maximum' do
- it 'should create a MAX node' do
+ describe "#maximum" do
+ it "should create a MAX node" do
relation = Table.new(:users)
relation[:id].maximum.must_be_kind_of Nodes::Max
end
- it 'should generate proper SQL' do
+ it "should generate proper SQL" do
relation = Table.new(:users)
mgr = relation.project relation[:id].maximum
mgr.to_sql.must_be_like %{
@@ -341,13 +342,13 @@ module Arel
end
end
- describe '#minimum' do
- it 'should create a Min node' do
+ describe "#minimum" do
+ it "should create a Min node" do
relation = Table.new(:users)
relation[:id].minimum.must_be_kind_of Nodes::Min
end
- it 'should generate proper SQL' do
+ it "should generate proper SQL" do
relation = Table.new(:users)
mgr = relation.project relation[:id].minimum
mgr.to_sql.must_be_like %{
@@ -357,13 +358,13 @@ module Arel
end
end
- describe '#sum' do
- it 'should create a SUM node' do
+ describe "#sum" do
+ it "should create a SUM node" do
relation = Table.new(:users)
relation[:id].sum.must_be_kind_of Nodes::Sum
end
- it 'should generate the proper SQL' do
+ it "should generate the proper SQL" do
relation = Table.new(:users)
mgr = relation.project relation[:id].sum
mgr.to_sql.must_be_like %{
@@ -373,13 +374,13 @@ module Arel
end
end
- describe '#count' do
- it 'should return a count node' do
+ describe "#count" do
+ it "should return a count node" do
relation = Table.new(:users)
relation[:id].count.must_be_kind_of Nodes::Count
end
- it 'should take a distinct param' do
+ it "should take a distinct param" do
relation = Table.new(:users)
count = relation[:id].count(nil)
count.must_be_kind_of Nodes::Count
@@ -387,8 +388,8 @@ module Arel
end
end
- describe '#eq' do
- it 'should return an equality node' do
+ describe "#eq" do
+ it "should return an equality node" do
attribute = Attribute.new nil, nil
equality = attribute.eq 1
equality.left.must_equal attribute
@@ -396,7 +397,7 @@ module Arel
equality.must_be_kind_of Nodes::Equality
end
- it 'should generate = in sql' do
+ it "should generate = in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
mgr.where relation[:id].eq(10)
@@ -405,7 +406,7 @@ module Arel
}
end
- it 'should handle nil' do
+ it "should handle nil" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
mgr.where relation[:id].eq(nil)
@@ -415,152 +416,152 @@ module Arel
end
end
- describe '#eq_any' do
- it 'should create a Grouping node' do
+ describe "#eq_any" do
+ it "should create a Grouping node" do
relation = Table.new(:users)
- relation[:id].eq_any([1,2]).must_be_kind_of Nodes::Grouping
+ relation[:id].eq_any([1, 2]).must_be_kind_of Nodes::Grouping
end
- it 'should generate ORs in sql' do
+ it "should generate ORs in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:id].eq_any([1,2])
+ mgr.where relation[:id].eq_any([1, 2])
mgr.to_sql.must_be_like %{
SELECT "users"."id" FROM "users" WHERE ("users"."id" = 1 OR "users"."id" = 2)
}
end
- it 'should not eat input' do
+ it "should not eat input" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- values = [1,2]
+ values = [1, 2]
mgr.where relation[:id].eq_any(values)
- values.must_equal [1,2]
+ values.must_equal [1, 2]
end
end
- describe '#eq_all' do
- it 'should create a Grouping node' do
+ describe "#eq_all" do
+ it "should create a Grouping node" do
relation = Table.new(:users)
- relation[:id].eq_all([1,2]).must_be_kind_of Nodes::Grouping
+ relation[:id].eq_all([1, 2]).must_be_kind_of Nodes::Grouping
end
- it 'should generate ANDs in sql' do
+ it "should generate ANDs in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:id].eq_all([1,2])
+ mgr.where relation[:id].eq_all([1, 2])
mgr.to_sql.must_be_like %{
SELECT "users"."id" FROM "users" WHERE ("users"."id" = 1 AND "users"."id" = 2)
}
end
- it 'should not eat input' do
+ it "should not eat input" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- values = [1,2]
+ values = [1, 2]
mgr.where relation[:id].eq_all(values)
- values.must_equal [1,2]
+ values.must_equal [1, 2]
end
end
- describe '#matches' do
- it 'should create a Matches node' do
+ describe "#matches" do
+ it "should create a Matches node" do
relation = Table.new(:users)
- relation[:name].matches('%bacon%').must_be_kind_of Nodes::Matches
+ relation[:name].matches("%bacon%").must_be_kind_of Nodes::Matches
end
- it 'should generate LIKE in sql' do
+ it "should generate LIKE in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:name].matches('%bacon%')
+ mgr.where relation[:name].matches("%bacon%")
mgr.to_sql.must_be_like %{
SELECT "users"."id" FROM "users" WHERE "users"."name" LIKE '%bacon%'
}
end
end
- describe '#matches_any' do
- it 'should create a Grouping node' do
+ describe "#matches_any" do
+ it "should create a Grouping node" do
relation = Table.new(:users)
- relation[:name].matches_any(['%chunky%','%bacon%']).must_be_kind_of Nodes::Grouping
+ relation[:name].matches_any(["%chunky%", "%bacon%"]).must_be_kind_of Nodes::Grouping
end
- it 'should generate ORs in sql' do
+ it "should generate ORs in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:name].matches_any(['%chunky%','%bacon%'])
+ mgr.where relation[:name].matches_any(["%chunky%", "%bacon%"])
mgr.to_sql.must_be_like %{
SELECT "users"."id" FROM "users" WHERE ("users"."name" LIKE '%chunky%' OR "users"."name" LIKE '%bacon%')
}
end
end
- describe '#matches_all' do
- it 'should create a Grouping node' do
+ describe "#matches_all" do
+ it "should create a Grouping node" do
relation = Table.new(:users)
- relation[:name].matches_all(['%chunky%','%bacon%']).must_be_kind_of Nodes::Grouping
+ relation[:name].matches_all(["%chunky%", "%bacon%"]).must_be_kind_of Nodes::Grouping
end
- it 'should generate ANDs in sql' do
+ it "should generate ANDs in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:name].matches_all(['%chunky%','%bacon%'])
+ mgr.where relation[:name].matches_all(["%chunky%", "%bacon%"])
mgr.to_sql.must_be_like %{
SELECT "users"."id" FROM "users" WHERE ("users"."name" LIKE '%chunky%' AND "users"."name" LIKE '%bacon%')
}
end
end
- describe '#does_not_match' do
- it 'should create a DoesNotMatch node' do
+ describe "#does_not_match" do
+ it "should create a DoesNotMatch node" do
relation = Table.new(:users)
- relation[:name].does_not_match('%bacon%').must_be_kind_of Nodes::DoesNotMatch
+ relation[:name].does_not_match("%bacon%").must_be_kind_of Nodes::DoesNotMatch
end
- it 'should generate NOT LIKE in sql' do
+ it "should generate NOT LIKE in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:name].does_not_match('%bacon%')
+ mgr.where relation[:name].does_not_match("%bacon%")
mgr.to_sql.must_be_like %{
SELECT "users"."id" FROM "users" WHERE "users"."name" NOT LIKE '%bacon%'
}
end
end
- describe '#does_not_match_any' do
- it 'should create a Grouping node' do
+ describe "#does_not_match_any" do
+ it "should create a Grouping node" do
relation = Table.new(:users)
- relation[:name].does_not_match_any(['%chunky%','%bacon%']).must_be_kind_of Nodes::Grouping
+ relation[:name].does_not_match_any(["%chunky%", "%bacon%"]).must_be_kind_of Nodes::Grouping
end
- it 'should generate ORs in sql' do
+ it "should generate ORs in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:name].does_not_match_any(['%chunky%','%bacon%'])
+ mgr.where relation[:name].does_not_match_any(["%chunky%", "%bacon%"])
mgr.to_sql.must_be_like %{
SELECT "users"."id" FROM "users" WHERE ("users"."name" NOT LIKE '%chunky%' OR "users"."name" NOT LIKE '%bacon%')
}
end
end
- describe '#does_not_match_all' do
- it 'should create a Grouping node' do
+ describe "#does_not_match_all" do
+ it "should create a Grouping node" do
relation = Table.new(:users)
- relation[:name].does_not_match_all(['%chunky%','%bacon%']).must_be_kind_of Nodes::Grouping
+ relation[:name].does_not_match_all(["%chunky%", "%bacon%"]).must_be_kind_of Nodes::Grouping
end
- it 'should generate ANDs in sql' do
+ it "should generate ANDs in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:name].does_not_match_all(['%chunky%','%bacon%'])
+ mgr.where relation[:name].does_not_match_all(["%chunky%", "%bacon%"])
mgr.to_sql.must_be_like %{
SELECT "users"."id" FROM "users" WHERE ("users"."name" NOT LIKE '%chunky%' AND "users"."name" NOT LIKE '%bacon%')
}
end
end
- describe 'with a range' do
- it 'can be constructed with a standard range' do
+ describe "with a range" do
+ it "can be constructed with a standard range" do
attribute = Attribute.new nil, nil
node = attribute.between(1..3)
@@ -573,7 +574,7 @@ module Arel
)
end
- it 'can be constructed with a range starting from -Infinity' do
+ it "can be constructed with a range starting from -Infinity" do
attribute = Attribute.new nil, nil
node = attribute.between(-::Float::INFINITY..3)
@@ -583,7 +584,7 @@ module Arel
)
end
- it 'can be constructed with a quoted range starting from -Infinity' do
+ it "can be constructed with a quoted range starting from -Infinity" do
attribute = Attribute.new nil, nil
node = attribute.between(quoted_range(-::Float::INFINITY, 3, false))
@@ -593,7 +594,7 @@ module Arel
)
end
- it 'can be constructed with an exclusive range starting from -Infinity' do
+ it "can be constructed with an exclusive range starting from -Infinity" do
attribute = Attribute.new nil, nil
node = attribute.between(-::Float::INFINITY...3)
@@ -603,7 +604,7 @@ module Arel
)
end
- it 'can be constructed with a quoted exclusive range starting from -Infinity' do
+ it "can be constructed with a quoted exclusive range starting from -Infinity" do
attribute = Attribute.new nil, nil
node = attribute.between(quoted_range(-::Float::INFINITY, 3, true))
@@ -613,14 +614,14 @@ module Arel
)
end
- it 'can be constructed with an infinite range' do
+ it "can be constructed with an infinite range" do
attribute = Attribute.new nil, nil
node = attribute.between(-::Float::INFINITY..::Float::INFINITY)
node.must_equal Nodes::NotIn.new(attribute, [])
end
- it 'can be constructed with a quoted infinite range' do
+ it "can be constructed with a quoted infinite range" do
attribute = Attribute.new nil, nil
node = attribute.between(quoted_range(-::Float::INFINITY, ::Float::INFINITY, false))
@@ -628,7 +629,7 @@ module Arel
end
- it 'can be constructed with a range ending at Infinity' do
+ it "can be constructed with a range ending at Infinity" do
attribute = Attribute.new nil, nil
node = attribute.between(0..::Float::INFINITY)
@@ -638,7 +639,7 @@ module Arel
)
end
- it 'can be constructed with a quoted range ending at Infinity' do
+ it "can be constructed with a quoted range ending at Infinity" do
attribute = Attribute.new nil, nil
node = attribute.between(quoted_range(0, ::Float::INFINITY, false))
@@ -648,7 +649,7 @@ module Arel
)
end
- it 'can be constructed with an exclusive range' do
+ it "can be constructed with an exclusive range" do
attribute = Attribute.new nil, nil
node = attribute.between(0...3)
@@ -673,11 +674,11 @@ module Arel
end
end
- describe '#in' do
- it 'can be constructed with a subquery' do
+ describe "#in" do
+ it "can be constructed with a subquery" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:name].does_not_match_all(['%chunky%','%bacon%'])
+ mgr.where relation[:name].does_not_match_all(["%chunky%", "%bacon%"])
attribute = Attribute.new nil, nil
node = attribute.in(mgr)
@@ -685,7 +686,7 @@ module Arel
node.must_equal Nodes::In.new(attribute, mgr.ast)
end
- it 'can be constructed with a list' do
+ it "can be constructed with a list" do
attribute = Attribute.new nil, nil
node = attribute.in([1, 2, 3])
@@ -699,7 +700,7 @@ module Arel
)
end
- it 'can be constructed with a random object' do
+ it "can be constructed with a random object" do
attribute = Attribute.new nil, nil
random_object = Object.new
node = attribute.in(random_object)
@@ -710,58 +711,58 @@ module Arel
)
end
- it 'should generate IN in sql' do
+ it "should generate IN in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:id].in([1,2,3])
+ mgr.where relation[:id].in([1, 2, 3])
mgr.to_sql.must_be_like %{
SELECT "users"."id" FROM "users" WHERE "users"."id" IN (1, 2, 3)
}
end
end
- describe '#in_any' do
- it 'should create a Grouping node' do
+ describe "#in_any" do
+ it "should create a Grouping node" do
relation = Table.new(:users)
- relation[:id].in_any([1,2]).must_be_kind_of Nodes::Grouping
+ relation[:id].in_any([1, 2]).must_be_kind_of Nodes::Grouping
end
- it 'should generate ORs in sql' do
+ it "should generate ORs in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:id].in_any([[1,2], [3,4]])
+ mgr.where relation[:id].in_any([[1, 2], [3, 4]])
mgr.to_sql.must_be_like %{
SELECT "users"."id" FROM "users" WHERE ("users"."id" IN (1, 2) OR "users"."id" IN (3, 4))
}
end
end
- describe '#in_all' do
- it 'should create a Grouping node' do
+ describe "#in_all" do
+ it "should create a Grouping node" do
relation = Table.new(:users)
- relation[:id].in_all([1,2]).must_be_kind_of Nodes::Grouping
+ relation[:id].in_all([1, 2]).must_be_kind_of Nodes::Grouping
end
- it 'should generate ANDs in sql' do
+ it "should generate ANDs in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:id].in_all([[1,2], [3,4]])
+ mgr.where relation[:id].in_all([[1, 2], [3, 4]])
mgr.to_sql.must_be_like %{
SELECT "users"."id" FROM "users" WHERE ("users"."id" IN (1, 2) AND "users"."id" IN (3, 4))
}
end
end
- describe 'with a range' do
- it 'can be constructed with a standard range' do
+ describe "with a range" do
+ it "can be constructed with a standard range" do
attribute = Attribute.new nil, nil
node = attribute.not_between(1..3)
node.must_equal Nodes::Grouping.new(Nodes::Or.new(
- Nodes::LessThan.new(
- attribute,
- Nodes::Casted.new(1, attribute)
- ),
+ Nodes::LessThan.new(
+ attribute,
+ Nodes::Casted.new(1, attribute)
+ ),
Nodes::GreaterThan.new(
attribute,
Nodes::Casted.new(3, attribute)
@@ -769,7 +770,7 @@ module Arel
))
end
- it 'can be constructed with a range starting from -Infinity' do
+ it "can be constructed with a range starting from -Infinity" do
attribute = Attribute.new nil, nil
node = attribute.not_between(-::Float::INFINITY..3)
@@ -779,7 +780,7 @@ module Arel
)
end
- it 'can be constructed with an exclusive range starting from -Infinity' do
+ it "can be constructed with an exclusive range starting from -Infinity" do
attribute = Attribute.new nil, nil
node = attribute.not_between(-::Float::INFINITY...3)
@@ -789,14 +790,14 @@ module Arel
)
end
- it 'can be constructed with an infinite range' do
+ it "can be constructed with an infinite range" do
attribute = Attribute.new nil, nil
node = attribute.not_between(-::Float::INFINITY..::Float::INFINITY)
node.must_equal Nodes::In.new(attribute, [])
end
- it 'can be constructed with a range ending at Infinity' do
+ it "can be constructed with a range ending at Infinity" do
attribute = Attribute.new nil, nil
node = attribute.not_between(0..::Float::INFINITY)
@@ -806,15 +807,15 @@ module Arel
)
end
- it 'can be constructed with an exclusive range' do
+ it "can be constructed with an exclusive range" do
attribute = Attribute.new nil, nil
node = attribute.not_between(0...3)
node.must_equal Nodes::Grouping.new(Nodes::Or.new(
- Nodes::LessThan.new(
- attribute,
- Nodes::Casted.new(0, attribute)
- ),
+ Nodes::LessThan.new(
+ attribute,
+ Nodes::Casted.new(0, attribute)
+ ),
Nodes::GreaterThanOrEqual.new(
attribute,
Nodes::Casted.new(3, attribute)
@@ -823,11 +824,11 @@ module Arel
end
end
- describe '#not_in' do
- it 'can be constructed with a subquery' do
+ describe "#not_in" do
+ it "can be constructed with a subquery" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:name].does_not_match_all(['%chunky%','%bacon%'])
+ mgr.where relation[:name].does_not_match_all(["%chunky%", "%bacon%"])
attribute = Attribute.new nil, nil
node = attribute.not_in(mgr)
@@ -835,7 +836,7 @@ module Arel
node.must_equal Nodes::NotIn.new(attribute, mgr.ast)
end
- it 'can be constructed with a Union' do
+ it "can be constructed with a Union" do
relation = Table.new(:users)
mgr1 = relation.project(relation[:id])
mgr2 = relation.project(relation[:id])
@@ -847,7 +848,7 @@ module Arel
}
end
- it 'can be constructed with a list' do
+ it "can be constructed with a list" do
attribute = Attribute.new nil, nil
node = attribute.not_in([1, 2, 3])
@@ -861,7 +862,7 @@ module Arel
)
end
- it 'can be constructed with a random object' do
+ it "can be constructed with a random object" do
attribute = Attribute.new nil, nil
random_object = Object.new
node = attribute.not_in(random_object)
@@ -872,71 +873,71 @@ module Arel
)
end
- it 'should generate NOT IN in sql' do
+ it "should generate NOT IN in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:id].not_in([1,2,3])
+ mgr.where relation[:id].not_in([1, 2, 3])
mgr.to_sql.must_be_like %{
SELECT "users"."id" FROM "users" WHERE "users"."id" NOT IN (1, 2, 3)
}
end
end
- describe '#not_in_any' do
- it 'should create a Grouping node' do
+ describe "#not_in_any" do
+ it "should create a Grouping node" do
relation = Table.new(:users)
- relation[:id].not_in_any([1,2]).must_be_kind_of Nodes::Grouping
+ relation[:id].not_in_any([1, 2]).must_be_kind_of Nodes::Grouping
end
- it 'should generate ORs in sql' do
+ it "should generate ORs in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:id].not_in_any([[1,2], [3,4]])
+ mgr.where relation[:id].not_in_any([[1, 2], [3, 4]])
mgr.to_sql.must_be_like %{
SELECT "users"."id" FROM "users" WHERE ("users"."id" NOT IN (1, 2) OR "users"."id" NOT IN (3, 4))
}
end
end
- describe '#not_in_all' do
- it 'should create a Grouping node' do
+ describe "#not_in_all" do
+ it "should create a Grouping node" do
relation = Table.new(:users)
- relation[:id].not_in_all([1,2]).must_be_kind_of Nodes::Grouping
+ relation[:id].not_in_all([1, 2]).must_be_kind_of Nodes::Grouping
end
- it 'should generate ANDs in sql' do
+ it "should generate ANDs in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:id].not_in_all([[1,2], [3,4]])
+ mgr.where relation[:id].not_in_all([[1, 2], [3, 4]])
mgr.to_sql.must_be_like %{
SELECT "users"."id" FROM "users" WHERE ("users"."id" NOT IN (1, 2) AND "users"."id" NOT IN (3, 4))
}
end
end
- describe '#eq_all' do
- it 'should create a Grouping node' do
+ describe "#eq_all" do
+ it "should create a Grouping node" do
relation = Table.new(:users)
- relation[:id].eq_all([1,2]).must_be_kind_of Nodes::Grouping
+ relation[:id].eq_all([1, 2]).must_be_kind_of Nodes::Grouping
end
- it 'should generate ANDs in sql' do
+ it "should generate ANDs in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
- mgr.where relation[:id].eq_all([1,2])
+ mgr.where relation[:id].eq_all([1, 2])
mgr.to_sql.must_be_like %{
SELECT "users"."id" FROM "users" WHERE ("users"."id" = 1 AND "users"."id" = 2)
}
end
end
- describe '#asc' do
- it 'should create an Ascending node' do
+ describe "#asc" do
+ it "should create an Ascending node" do
relation = Table.new(:users)
relation[:id].asc.must_be_kind_of Nodes::Ascending
end
- it 'should generate ASC in sql' do
+ it "should generate ASC in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
mgr.order relation[:id].asc
@@ -946,13 +947,13 @@ module Arel
end
end
- describe '#desc' do
- it 'should create a Descending node' do
+ describe "#desc" do
+ it "should create a Descending node" do
relation = Table.new(:users)
relation[:id].desc.must_be_kind_of Nodes::Descending
end
- it 'should generate DESC in sql' do
+ it "should generate DESC in sql" do
relation = Table.new(:users)
mgr = relation.project relation[:id]
mgr.order relation[:id].desc
@@ -962,18 +963,18 @@ module Arel
end
end
- describe 'equality' do
- describe '#to_sql' do
- it 'should produce sql' do
+ describe "equality" do
+ describe "#to_sql" do
+ it "should produce sql" do
table = Table.new :users
- condition = table['id'].eq 1
+ condition = table["id"].eq 1
condition.to_sql.must_equal '"users"."id" = 1'
end
end
end
- describe 'type casting' do
- it 'does not type cast by default' do
+ describe "type casting" do
+ it "does not type cast by default" do
table = Table.new(:foo)
condition = table["id"].eq("1")
@@ -981,7 +982,7 @@ module Arel
condition.to_sql.must_equal %("foo"."id" = '1')
end
- it 'type casts when given an explicit caster' do
+ it "type casts when given an explicit caster" do
fake_caster = Object.new
def fake_caster.type_cast_for_database(attr_name, value)
if attr_name == "id"
@@ -997,7 +998,7 @@ module Arel
condition.to_sql.must_equal %("foo"."id" = 1 AND "foo"."other_id" = '2')
end
- it 'does not type cast SqlLiteral nodes' do
+ it "does not type cast SqlLiteral nodes" do
fake_caster = Object.new
def fake_caster.type_cast_for_database(attr_name, value)
value.to_i