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.26 spec/unit/resource/key/relation_spec.rb
transcriber-0.0.25 spec/unit/resource/key/relation_spec.rb
transcriber-0.0.24 spec/unit/resource/key/relation_spec.rb
transcriber-0.0.23 spec/unit/resource/key/relation_spec.rb
transcriber-0.0.22 spec/unit/resource/key/relation_spec.rb
transcriber-0.0.21 spec/unit/resource/key/relation_spec.rb
transcriber-0.0.20 spec/unit/resource/key/relation_spec.rb
transcriber-0.0.19 spec/unit/resource/key/relation_spec.rb
transcriber-0.0.18 spec/unit/resource/key/relation_spec.rb
transcriber-0.0.17 spec/unit/resource/key/relation_spec.rb
transcriber-0.0.16 spec/unit/resource/key/relation_spec.rb
transcriber-0.0.15 spec/unit/resource/key/relation_spec.rb
transcriber-0.0.14 spec/unit/resource/key/relation_spec.rb
transcriber-0.0.13 spec/unit/resource/key/relation_spec.rb
transcriber-0.0.12 spec/unit/resource/key/relation_spec.rb
transcriber-0.0.11 spec/unit/resource/key/relation_spec.rb
transcriber-0.0.10 spec/unit/resource/key/relation_spec.rb
transcriber-0.0.9 spec/unit/resource/key/relation_spec.rb
transcriber-0.0.8 spec/unit/resource/key/relation_spec.rb
transcriber-0.0.7 spec/unit/resource/key/relation_spec.rb