Sha256: 35e17f93fe00d9b619919ec8dfe10c9ab1a758cae5111af3a15b2b702c514d31

Contents?: true

Size: 1.51 KB

Versions: 25

Compression:

Stored size: 1.51 KB

Contents

require 'spec_helper'

describe Resource::Relation do
  it "is a relation" do
    Resource::Relation.superclass.should == Resource::Association
  end

  describe "#has?" do
    context "when it has one resource" do
      subject do
        Resource::Relation.new(:service, many: false, has: true)
      end

      it "returns true" do
        subject.has?.should be_true
      end
    end

    context "when it has many resources" do
      subject do
        Resource::Relation.new(:service, many: true, has: true)
      end

      it "returns true" do
        subject.has?.should be_true
      end
    end

    context "when it belongs to a resource" do
      subject do
        Resource::Relation.new(:service, many: false, has: false)
      end

      it "returns true" do
        subject.has?.should be_false
      end
    end
  end

  describe "#belongs?" do
    context "when it belongs to a resource" do
      subject do
        Resource::Relation.new(:service, many: false, has: false)
      end

      it "returns true" do
        subject.belongs?.should be_true
      end
    end

    context "when it has one resource" do
      subject do
        Resource::Relation.new(:service, many: false, has: true)
      end

      it "returns true" do
        subject.belongs?.should be_false
      end
    end

    context "when it has many resources" do
      subject do
        Resource::Relation.new(:service, many: true, has: true)
      end

      it "returns true" do
        subject.belongs?.should be_false
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
transcriber-0.0.6 spec/unit/resource/key/relation_spec.rb
transcriber-0.0.5 spec/unit/resource/key/relation_spec.rb
transcriber-0.0.4 spec/unit/resource/key/relation_spec.rb
transcriber-0.0.3 spec/unit/resource/key/relation_spec.rb
transcriber-0.0.2 spec/unit/resource/key/relation_spec.rb