From 83c27c0b5e2e341307b7a160d831fb930a9552b4 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Fri, 12 Mar 2010 12:51:20 -0800 Subject: Attributes should be typed --- spec/arel/algebra/integration/basic_spec.rb | 41 +++++++++++++++++------------ 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'spec/arel/algebra') 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 -- cgit v1.2.3