diff options
author | Bryan Helmkamp <bryan@brynary.com> | 2009-05-17 15:41:49 -0400 |
---|---|---|
committer | Bryan Helmkamp <bryan@brynary.com> | 2009-05-17 15:41:49 -0400 |
commit | 4c71e3b2ea4b8da574954cbd8a26d12f2cc640d0 (patch) | |
tree | 94cd4c2d1a9d1f2c25cf5f04be9aaa8b2fb888fc /spec/arel/engines/memory | |
parent | a7aacd29460aa137c3b06ee214ff8ffdff8ee365 (diff) | |
download | rails-4c71e3b2ea4b8da574954cbd8a26d12f2cc640d0.tar.gz rails-4c71e3b2ea4b8da574954cbd8a26d12f2cc640d0.tar.bz2 rails-4c71e3b2ea4b8da574954cbd8a26d12f2cc640d0.zip |
removed duplicates from sql tests
Conflicts:
spec/arel/engines/sql/unit/predicates/binary_spec.rb
spec/arel/engines/sql/unit/predicates/equality_spec.rb
spec/arel/engines/sql/unit/primitives/attribute_spec.rb
spec/arel/engines/sql/unit/primitives/expression_spec.rb
spec/arel/engines/sql/unit/relations/alias_spec.rb
spec/arel/engines/sql/unit/relations/join_spec.rb
spec/arel/engines/sql/unit/relations/project_spec.rb
spec/arel/engines/sql/unit/relations/relation_spec.rb
spec/arel/engines/sql/unit/relations/table_spec.rb
spec/arel/engines/sql/unit/relations/where_spec.rb
spec/arel/engines/sql/unit/session/session_spec.rb
Diffstat (limited to 'spec/arel/engines/memory')
-rw-r--r-- | spec/arel/engines/memory/unit/relations/array_spec.rb | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/spec/arel/engines/memory/unit/relations/array_spec.rb b/spec/arel/engines/memory/unit/relations/array_spec.rb new file mode 100644 index 0000000000..8d40858c5f --- /dev/null +++ b/spec/arel/engines/memory/unit/relations/array_spec.rb @@ -0,0 +1,87 @@ +require File.join(File.dirname(__FILE__), '..', '..', '..', '..', '..', 'spec_helper') + +module Arel + describe Array do + before do + @relation = Array.new([ + [1, 'duck' ], + [2, 'duck' ], + [3, 'goose'] + ], [:id, :name]) + end + + describe '#attributes' do + it 'manufactures attributes corresponding to the names given on construction' do + @relation.attributes.should == [ + Attribute.new(@relation, :id), + Attribute.new(@relation, :name) + ] + end + end + + describe '#call' do + it "manufactures an array of hashes of attributes to values" do + @relation.call.should == [ + { @relation[:id] => 1, @relation[:name] => 'duck' }, + { @relation[:id] => 2, @relation[:name] => 'duck' }, + { @relation[:id] => 3, @relation[:name] => 'goose' } + ] + end + + describe 'where' do + it 'filters the relation with the provided predicate' do + @relation.where(@relation[:id].lt(3)).call.should == [ + { @relation[:id] => 1, @relation[:name] => 'duck' }, + { @relation[:id] => 2, @relation[:name] => 'duck' } + ] + end + end + + describe 'group' do + it 'sorts the relation with the provided ordering' do + end + end + + describe 'order' do + it 'sorts the relation with the provided ordering' do + @relation.order(@relation[:id].desc).call.should == [ + { @relation[:id] => 3, @relation[:name] => 'goose' }, + { @relation[:id] => 2, @relation[:name] => 'duck' }, + { @relation[:id] => 1, @relation[:name] => 'duck' } + ] + end + end + + describe 'project' do + it 'projects' do + @relation.project(@relation[:id]).call.should == [ + { @relation[:id] => 1 }, + { @relation[:id] => 2 }, + { @relation[:id] => 3 } + ] + end + end + + describe 'skip' do + it 'slices' do + @relation.skip(1).call.should == [ + { @relation[:id] => 2, @relation[:name] => 'duck' }, + { @relation[:id] => 3, @relation[:name] => 'goose' } + ] + end + end + + describe 'take' do + it 'dices' do + @relation.take(2).call.should == [ + { @relation[:id] => 1, @relation[:name] => 'duck' }, + { @relation[:id] => 2, @relation[:name] => 'duck' } + ] + end + end + + describe 'join' do + end + end + end +end
\ No newline at end of file |