Sha256: 3d0963b08a6ecd65e6623f31d4e339afe54258b2cb38c20ba47c32a22c2f2661

Contents?: true

Size: 1.61 KB

Versions: 4

Compression:

Stored size: 1.61 KB

Contents

require 'spec_helper'

module Ripple
  module Document
    describe self do
      describe "#to_link" do
        let(:tag)      { 'invoices' }
        let(:document) { Invoice.new }
        let(:to_link)  { document.to_link(tag) }

        it "returns a #{described_class}::Link" do
          to_link.should be_a(Link)
        end

        it "sets the document to this document" do
          to_link.send(:document).should equal(document)
        end

        it "sets the tag to the given tag" do
          to_link.tag.should == tag
        end
      end
    end

    describe Link do
      let(:key)      { 'the-invoice-key' }
      let(:tag)      { 'invoices' }
      let(:document) { Invoice.new { |i| i.key = key } }
      let(:link)     { described_class.new(document, tag) }

      it 'does not fetch the key immediately' do
        document.should_not_receive(:key)
        link
      end

      describe '#key' do
        it "returns the document's key" do
          link.key.should == key
        end
      end

      describe '#bucket' do
        it "returns the bucket name from the document class" do
          link.bucket.should == Invoice.bucket_name
        end
      end

      describe '#tag' do
        it 'returns the tag passed to the constructor' do
          link.tag.should == tag
        end
      end

      describe "#hash" do
        it 'does not use the key' do
          document.should_not_receive(:key)
          link.hash
        end

        it "uses the document's #hash" do
          document.should_receive(:hash).and_return(1234)
          link.hash.should == 1234
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 3 rubygems

Version Path
wyngle-ripple-0.1.0 spec/ripple/document/link_spec.rb
ripple-1.0.0.beta2 spec/ripple/document/link_spec.rb
seomoz-ripple-1.0.0.pre spec/ripple/document/link_spec.rb
ripple-1.0.0.beta spec/ripple/document/link_spec.rb