Skip to content

Commit

Permalink
- Remove unnecessary complexity for callback specs
Browse files Browse the repository at this point in the history
  • Loading branch information
arunthampi committed Jan 23, 2008
1 parent fae252e commit 16551af
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 20 deletions.
7 changes: 2 additions & 5 deletions spec/base/after_delete_spec.rb
Expand Up @@ -65,17 +65,14 @@ class Person < ActiveCouch::Base
p.save
# Delete should return true...
p.delete.should == true
# ...and then delete_status must be "Deleted McLovin"
p.delete_status.should == "Deleted McLovin"
end
end

describe "ActiveCouch::Base #after_save method with an Object (which implements after_save) as argument" do
before(:each) do
class DeleteStatusSetter
def initialize(attribute)
@attribute = attribute
end

def after_delete(record)
record.delete_status = 'Deleted McLovin'
end
Expand All @@ -86,7 +83,7 @@ class Person < ActiveCouch::Base
has :name
has :delete_status
# Callback, after the actual save happens
after_delete DeleteStatusSetter.new("delete_status")
after_delete DeleteStatusSetter.new
end
# Migration needed for this spec
ActiveCouch::Migrator.create_database('http://localhost:5984/', 'people')
Expand Down
6 changes: 1 addition & 5 deletions spec/base/after_save_spec.rb
Expand Up @@ -68,10 +68,6 @@ class Person < ActiveCouch::Base
describe "ActiveCouch::Base #after_save method with an Object (which implements after_save) as argument" do
before(:each) do
class RevisionSetter
def initialize(attribute)
@attribute = attribute
end

def after_save(record)
record.saved_revision = record.rev
end
Expand All @@ -82,7 +78,7 @@ class Person < ActiveCouch::Base
has :name
has :saved_revision
# Callback, after the actual save happens
after_save RevisionSetter.new("saved_revision")
after_save RevisionSetter.new
end
# Migration needed for this spec
ActiveCouch::Migrator.create_database('http://localhost:5984/', 'people')
Expand Down
6 changes: 1 addition & 5 deletions spec/base/before_delete_spec.rb
Expand Up @@ -72,10 +72,6 @@ class Person < ActiveCouch::Base
describe "ActiveCouch::Base #before_save method with an Object (which implements before_save) as argument" do
before(:each) do
class AgeSetter
def initialize(attribute)
@attribute = attribute
end

def before_delete(record)
record.age = 0
end
Expand All @@ -86,7 +82,7 @@ class Person < ActiveCouch::Base
has :name
has :age, :which_is => :number
# Callback, before the actual save happens
before_delete AgeSetter.new("age")
before_delete AgeSetter.new
end
# Migration needed for this spec
ActiveCouch::Migrator.create_database('http://localhost:5984/', 'people')
Expand Down
6 changes: 1 addition & 5 deletions spec/base/before_save_spec.rb
Expand Up @@ -66,10 +66,6 @@ class Person < ActiveCouch::Base
describe "ActiveCouch::Base #before_save method with an Object (which implements before_save) as argument" do
before(:each) do
class NameSetter
def initialize(attribute)
@attribute = attribute
end

def before_save(record)
record.first_name = 'Seth'
end
Expand All @@ -79,7 +75,7 @@ class Person < ActiveCouch::Base
site 'http://localhost:5984/'
has :first_name; has :last_name
# Callback, before the actual save happens
before_save NameSetter.new("first_name")
before_save NameSetter.new
end

# Migration needed for this spec
Expand Down

0 comments on commit 16551af

Please sign in to comment.