Sha256: b2593aa4002d1a17cff2adcbbd81f95173c6efb2b335654cdd2bb4357658b5ab

Contents?: true

Size: 927 Bytes

Versions: 1

Compression:

Stored size: 927 Bytes

Contents

require "spec_helper"

describe Afterparty do
  describe "#load" do
    it "should constantize any missing Classes while loading" do
      obj = TestJob.new
      dump = YAML.dump(obj)
      YAML.stub(:load) do
        YAML.unstub(:load)
        raise ArgumentError, "undefined class/module TestJob"
      end
      String.any_instance.should_receive(:constantize).once
      Afterparty.load(dump).should_not be_nil
    end

    it "returns nil when an exception is raised in YAML.load" do
      YAML.stub(:load){ raise Exception }
      Afterparty.load("anything").should be_nil
    end
  end

  describe "#job_valid?" do
    it "returns false unless job responds to #execute_at" do
      job = {}
      Afterparty.job_valid?(job).should be_false
    end

    it "returns false if #execute_at returns nil" do
      job = TestJob.new
      job.execute_at = nil
      Afterparty.job_valid?(job).should be_false
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
afterparty-0.2.0 spec/afterparty_spec.rb