Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

43 lines (36 sloc) 1.387 kb
require 'spec_helper'
class StoryReader
def read(story)
"Epilog: #{story.tell}"
end
end
describe Delayed::PerformableMethod do
it "should ignore ActiveRecord::RecordNotFound errors because they are permanent" do
story = Story.create :text => 'Once upon...'
p = Delayed::PerformableMethod.new(story, :tell, [])
story.destroy
lambda { p.perform }.should_not raise_error
end
it "should store the object as string if its an active record" do
story = Story.create :text => 'Once upon...'
p = Delayed::PerformableMethod.new(story, :tell, [])
p.class.should == Delayed::PerformableMethod
p.object.should == story
p.method.should == :tell
p.args.should == []
p.perform.should == 'Once upon...'
end
it "should allow class methods to be called on ActiveRecord models" do
p = Delayed::PerformableMethod.new(Story, :count, [])
lambda { p.perform.should be_kind_of(Fixnum) }.should_not raise_error
end
it "should store arguments as string if they are active record objects" do
story = Story.create :text => 'Once upon...'
reader = StoryReader.new
p = Delayed::PerformableMethod.new(reader, :read, [story])
p.class.should == Delayed::PerformableMethod
p.method.should == :read
p.args.should == [story]
p.perform.should == 'Epilog: Once upon...'
end
end
Jump to Line
Something went wrong with that request. Please try again.