Sha256: d43cbcb8fd594768431ca74fbdaac9962b91e4807206d13468e00ce9aecfcf70

Contents?: true

Size: 1.52 KB

Versions: 27

Compression:

Stored size: 1.52 KB

Contents

require 'spec_helper'

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

  describe "#has?" do
    context "when it has one resource" do
      subject do
        RestModel::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
        RestModel::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
        RestModel::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
        RestModel::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
        RestModel::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
        RestModel::Relation.new(:service, many: true, has: true)
      end

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

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
rest_model-0.2.1 spec/unit/key/relation_spec.rb
rest_model-0.2.0 spec/unit/key/relation_spec.rb
rest_model-0.1.24 spec/unit/key/relation_spec.rb
rest_model-0.1.23 spec/unit/key/relation_spec.rb
rest_model-0.1.22 spec/unit/key/relation_spec.rb
rest_model-0.1.21 spec/unit/key/relation_spec.rb
rest_model-0.1.20 spec/unit/key/relation_spec.rb
rest_model-0.1.19 spec/unit/key/relation_spec.rb
rest_model-0.1.18 spec/unit/key/relation_spec.rb
rest_model-0.1.17 spec/unit/key/relation_spec.rb
rest_model-0.1.16 spec/unit/key/relation_spec.rb
rest_model-0.1.15 spec/unit/key/relation_spec.rb
rest_model-0.1.14 spec/unit/key/relation_spec.rb
rest_model-0.1.13 spec/unit/key/relation_spec.rb
rest_model-0.1.12 spec/unit/key/relation_spec.rb
rest_model-0.1.11 spec/unit/key/relation_spec.rb
rest_model-0.1.10 spec/unit/key/relation_spec.rb
rest_model-0.1.9 spec/unit/key/relation_spec.rb
rest_model-0.1.8 spec/unit/key/relation_spec.rb
rest_model-0.1.7 spec/unit/key/relation_spec.rb