Skip to content

Commit

Permalink
Expand sql engine CRUD specs
Browse files Browse the repository at this point in the history
  • Loading branch information
brynary committed May 18, 2009
1 parent eede696 commit 976fb01
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions spec/arel/engines/sql/unit/engine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,41 @@
module Arel
describe Sql::Engine do
before do
@relation = Table.new(:users)
@users = Table.new(:users)
@users.delete
end

describe "CRUD" do
describe "#create" do
it "inserts into the relation" do
@relation.insert @relation[:name] => "Bryan"
@users.insert @users[:name] => "Bryan"
@users.first[@users[:name]].should == "Bryan"
end
end

describe "#read" do
it "reads from the relation" do
@relation.each do |row|
@users.insert @users[:name] => "Bryan"

@users.each do |row|
row[@users[:name]].should == "Bryan"
end
end
end

describe "#update" do
it "updates the relation" do
@relation.update @relation[:name] => "Bryan"
@users.insert @users[:name] => "Nick"
@users.update @users[:name] => "Bryan"
@users.first[@users[:name]].should == "Bryan"
end
end

describe "#delete" do
it "deletes from the relation" do
@relation.delete
@users.insert @users[:name] => "Bryan"
@users.delete
@users.first.should == nil
end
end
end
Expand Down

0 comments on commit 976fb01

Please sign in to comment.