Sha256: 75d38645d604fdcf5d7dd422a64be7b6572ab7b6125fe71bd277ca2ec51de203

Contents?: true

Size: 1.66 KB

Versions: 22

Compression:

Stored size: 1.66 KB

Contents

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  == "LOAD;Story;#{story.id}"
    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.send(:load, p.object) }.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    == ["LOAD;Story;#{story.id}"]
    p.perform.should == 'Epilog: Once upon...'
  end

  it "should not raise NoMethodError if target method is private" do
    clazz = Class.new do
      def private_method
      end
      private :private_method
    end
    lambda {
      Delayed::PerformableMethod.new(clazz.new, :private_method, [])
    }.should_not raise_error(NoMethodError)
  end
end

Version data entries

22 entries across 22 versions & 5 rubygems

Version Path
delayed_job-2.0.8 spec/performable_method_spec.rb
delayed_job_csi-2.0.7 spec/performable_method_spec.rb
delayed_job_with_named_queues-2.0.7.14 spec/performable_method_spec.rb
delayed_job_with_named_queues-2.0.7.13 spec/performable_method_spec.rb
delayed_job_with_named_queues-2.0.7.12 spec/performable_method_spec.rb
delayed_job_with_named_queues-2.0.7.11 spec/performable_method_spec.rb
delayed_job_with_named_queues-2.0.7.10 spec/performable_method_spec.rb
delayed_job_with_named_queues-2.0.7.9 spec/performable_method_spec.rb
delayed_job_with_named_queues-2.0.7.8 spec/performable_method_spec.rb
delayed_job_with_named_queues-2.0.7.7 spec/performable_method_spec.rb
delayed_job_with_named_queues-2.0.7.6 spec/performable_method_spec.rb
delayed-job-ajaycb-2.0.10 spec/performable_method_spec.rb
delayed_job_with_named_queues-2.0.7.5 spec/performable_method_spec.rb
delayed_job_with_named_queues-2.0.7.4 spec/performable_method_spec.rb
delayed_job_with_named_queues-2.0.7.3 spec/performable_method_spec.rb
delayed_job_with_named_queues-2.0.7.2 spec/performable_method_spec.rb
delayed_job_with_named_queues-2.0.7.1 spec/performable_method_spec.rb
yetanothernguyen-delayed_job-0.0.1 spec/performable_method_spec.rb
delayed_job-2.0.7 spec/performable_method_spec.rb
delayed_job-2.0.6 spec/performable_method_spec.rb