Sha256: 4c1431a5e5d31e7a52cd1defc1e0cafa940cb45f46c74c2773cd7370749f9bc8

Contents?: true

Size: 828 Bytes

Versions: 1

Compression:

Stored size: 828 Bytes

Contents

require 'spec_helper'

describe Outpost do
  describe "::obj_by_key" do
    context "no match" do
      it "returns nil" do
        Outpost.obj_by_key("nomatch").should eq nil
      end
      
      it "accepts nil argument" do
        Outpost.obj_by_key(nil).should eq nil
      end
    end
    
    context "match" do
      it "is nil if no record exists" do
        Outpost.obj_by_key("blogs/entry:9999999").should eq nil
      end
    
      it "finds and returns the record if everything matches" do
        post = create :post
        Outpost.obj_by_key(post.obj_key).should eq post
      end
    end
  end

  #---------------
  
  describe "::obj_by_key!" do
    it "raises an error if no object is found" do
      -> { Outpost.obj_by_key!("something") }.should raise_error ActiveRecord::RecordNotFound
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
outpost-cms-0.0.3 spec/lib/outpost_spec.rb