Skip to content

Commit

Permalink
removing test code from implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Aug 6, 2010
1 parent 4c43dac commit 0e9a9c7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
7 changes: 0 additions & 7 deletions lib/arel/algebra/relations/writes.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
module Arel
class Action < Compound
def == other
super || self.class === other && @relation == other.relation
end
end

class Deletion < Action
Expand All @@ -27,10 +24,6 @@ def call
engine.create(self)
end

def == other
super && @record == other.record
end

def eval
unoperated_rows + [Row.new(self, record.values.collect(&:value))]
end
Expand Down
21 changes: 17 additions & 4 deletions spec/algebra/unit/relations/relation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ module Arel
describe '#delete' do
it 'manufactures a deletion relation' do
Session.start do |s|
s.should_receive(:delete).with(Deletion.new(@relation))
s.should_receive(:delete) do |delete|
delete.relation.should == @relation
delete.should be_kind_of Deletion
end
@relation.delete
end
end
Expand All @@ -191,8 +194,13 @@ module Arel
describe '#insert' do
it 'manufactures an insertion relation' do
Session.start do |s|
record = { @relation[:name] => 'carl' }
s.should_receive(:create).with(Insert.new(@relation, record))
record = { @relation[:name] => Value.new('carl', @relation) }
s.should_receive(:create) do |insert|
insert.relation.should == @relation
insert.record.should == record
insert.should be_kind_of Insert
insert
end
@relation.insert(record)
end
end
Expand All @@ -202,7 +210,12 @@ module Arel
it 'manufactures an update relation' do
Session.start do |s|
assignments = { @relation[:name] => Value.new('bob', @relation) }
s.should_receive(:update).with(Update.new(@relation, assignments))
s.should_receive(:update) do |update|
update.relation.should == @relation
update.assignments.should == assignments
update.should be_kind_of Update
update
end
@relation.update(assignments)
end
end
Expand Down

0 comments on commit 0e9a9c7

Please sign in to comment.