diff options
author | Carl Lerche <carllerche@mac.com> | 2010-03-12 14:34:13 -0800 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2010-03-12 14:34:13 -0800 |
commit | 61916e408d86d19d1659cd8042de6503aecc6c98 (patch) | |
tree | 28cbadb9b39b44d993a033af5cf254655cdab58a /spec/support | |
parent | 83c27c0b5e2e341307b7a160d831fb930a9552b4 (diff) | |
download | rails-61916e408d86d19d1659cd8042de6503aecc6c98.tar.gz rails-61916e408d86d19d1659cd8042de6503aecc6c98.tar.bz2 rails-61916e408d86d19d1659cd8042de6503aecc6c98.zip |
Add a bunch of specs for attribute type casting.
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/model.rb | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/spec/support/model.rb b/spec/support/model.rb new file mode 100644 index 0000000000..bd4376efcb --- /dev/null +++ b/spec/support/model.rb @@ -0,0 +1,56 @@ +module Arel + module Testing + class Engine + attr_reader :rows + + def initialize + @rows = [] + end + + def supports(operation) + false + end + + def read(relation) + @rows.dup.map { |r| Row.new(relation, r) } + end + + def create(insert) + @rows << insert.record.tuple + insert + end + end + end + + class Model < Relation + attr_reader :engine, :attributes + + def self.build + relation = new + yield relation + relation + end + + def initialize + @attributes = [] + end + + def engine(engine = nil) + @engine = engine if engine + @engine + end + + def attribute(name, type) + @attributes << type.new(self, name) + end + + def format(attribute, value) + value + end + + def insert(row) + insert = super Arel::Row.new(self, row) + insert.record + end + end +end
\ No newline at end of file |