aboutsummaryrefslogtreecommitdiffstats
path: root/spec/relations/relation_spec.rb
blob: cfc1c1410b88f73c1c5cd725618c338742bd0278 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'spec_helper'

describe "Arel" do
  before :all do
    @engine = Arel::Testing::Engine.new
    @relation = Arel::Model.build do |r|
      r.engine @engine

      r.attribute :id,   Arel::Attributes::Integer
      r.attribute :name, Arel::Attributes::String
      r.attribute :age,  Arel::Attributes::Integer
    end
  end

  describe "Relation" do
    before :all do
      @expected = (1..20).map { |i| @relation.insert([i, "Name #{i % 6}", 2 * i]) }
    end

    it_should_behave_like 'A Relation'
  end

  describe "Relation" do
    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