diff options
author | Carl Lerche <carllerche@mac.com> | 2010-03-12 12:51:20 -0800 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2010-03-12 12:52:07 -0800 |
commit | 83c27c0b5e2e341307b7a160d831fb930a9552b4 (patch) | |
tree | fc41004d425cbc9827e82f550959ed40e8c12978 /spec/arel/algebra | |
parent | 602722922c8365afcb3e9bed3721d61756322353 (diff) | |
download | rails-83c27c0b5e2e341307b7a160d831fb930a9552b4.tar.gz rails-83c27c0b5e2e341307b7a160d831fb930a9552b4.tar.bz2 rails-83c27c0b5e2e341307b7a160d831fb930a9552b4.zip |
Attributes should be typed
Diffstat (limited to 'spec/arel/algebra')
-rw-r--r-- | spec/arel/algebra/integration/basic_spec.rb | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/spec/arel/algebra/integration/basic_spec.rb b/spec/arel/algebra/integration/basic_spec.rb index 84b8105f66..6ade5c40ac 100644 --- a/spec/arel/algebra/integration/basic_spec.rb +++ b/spec/arel/algebra/integration/basic_spec.rb @@ -29,8 +29,10 @@ class Thing < Arel::Relation attr_reader :engine, :attributes def initialize(engine, attributes) - @engine = engine - @attributes = attributes.map { |a| a.to_attribute(self) } + @engine, @attributes = engine, [] + attributes.each do |name, type| + @attributes << type.new(self, name) + end end def format(attribute, value) @@ -95,26 +97,31 @@ share_examples_for 'A Relation' do end end -describe "Arel::Relation" do - - before :all do - @engine = Arel::Testing::Engine.new - @relation = Thing.new(@engine, [:id, :name, :age]) - end +module Arel + describe "Relation" do - describe "..." do before :all do - @expected = (1..20).map { |i| @relation.insert([i, nil, 2 * i]) } + @engine = Testing::Engine.new + @relation = Thing.new(@engine, + :id => Attributes::Integer, + :name => Attributes::String, + :age => Attributes::Integer) end - it_should_behave_like 'A Relation' - end + describe "..." do + before :all do + @expected = (1..20).map { |i| @relation.insert([i, nil, 2 * i]) } + end - describe "#insert" do - it "inserts the row into the engine" do - @relation.insert([1, 'Foo', 10]) - @engine.rows.should == [[1, 'Foo', 10]] + it_should_behave_like 'A Relation' + end + + describe "#insert" do + it "inserts the row into the engine" do + @relation.insert([1, 'Foo', 10]) + @engine.rows.should == [[1, 'Foo', 10]] + end end - end + end end
\ No newline at end of file |