aboutsummaryrefslogtreecommitdiffstats
path: root/spec/arel
diff options
context:
space:
mode:
Diffstat (limited to 'spec/arel')
-rw-r--r--spec/arel/attributes/attribute_spec.rb25
-rw-r--r--spec/arel/table_spec.rb4
2 files changed, 27 insertions, 2 deletions
diff --git a/spec/arel/attributes/attribute_spec.rb b/spec/arel/attributes/attribute_spec.rb
index ae0f70c5ba..6679ca8b7a 100644
--- a/spec/arel/attributes/attribute_spec.rb
+++ b/spec/arel/attributes/attribute_spec.rb
@@ -3,6 +3,31 @@ require 'spec_helper'
module Arel
module Attributes
describe 'attribute' do
+ describe '#not_eq' do
+ it 'should create a NotEqual node' do
+ relation = Table.new(:users)
+ relation[:id].not_eq(10).should be_kind_of Nodes::NotEqual
+ end
+
+ it 'should generate != in sql' do
+ relation = Table.new(:users)
+ mgr = relation.project relation[:id]
+ mgr.where relation[:id].not_eq(10)
+ mgr.to_sql.should be_like %{
+ SELECT "users"."id" FROM "users" WHERE "users"."id" != 10
+ }
+ end
+
+ it 'should handle nil' do
+ relation = Table.new(:users)
+ mgr = relation.project relation[:id]
+ mgr.where relation[:id].not_eq(nil)
+ mgr.to_sql.should be_like %{
+ SELECT "users"."id" FROM "users" WHERE "users"."id" IS NOT NULL
+ }
+ end
+ end
+
describe '#gt' do
it 'should create a GreaterThan node' do
relation = Table.new(:users)
diff --git a/spec/arel/table_spec.rb b/spec/arel/table_spec.rb
index 6512ab310b..7cc0b20a25 100644
--- a/spec/arel/table_spec.rb
+++ b/spec/arel/table_spec.rb
@@ -120,7 +120,7 @@ module Arel
it 'returns a list of columns' do
columns = @relation.columns
check columns.length.should == 2
- columns.map { |x| x.name }.sort.should == %w{ name id }.sort
+ columns.map { |x| x.name.to_s }.sort.should == %w{ name id }.sort
end
end
@@ -136,7 +136,7 @@ module Arel
describe 'when given a', Symbol do
it "manufactures an attribute if the symbol names an attribute within the relation" do
column = @relation[:id]
- check column.name.should == 'id'
+ check column.name.should == :id
column.should be_kind_of Attributes::Integer
end
end