Sha256: 24c6f04b55ebe68abc074bf7c8210ba9b43af6750fbfa514ede3fdadf579cc37

Contents?: true

Size: 951 Bytes

Versions: 3

Compression:

Stored size: 951 Bytes

Contents

require 'spec_helper'

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

  describe "#has? and #belongs?" do
    context "when it has one resource" do
      subject        {RestModel::Relation.new(:service, many: false, has: true)}
      its(:has?)     {should be_true}
      its(:belongs?) {should be_false}
    end

    context "when it has many resources" do
      subject        {RestModel::Relation.new(:service, many: true, has: true)}
      its(:has?)     {should be_true}
      its(:belongs?) {should be_false}
    end

    context "when it belongs to a resource" do
      subject        {RestModel::Relation.new(:service, many: false, has: false)}
      its(:has?)     {should be_false}
      its(:belongs?) {should be_true}
    end
  end

  context "#relation?" do
    subject {RestModel::Relation.new(:example)}
    its(:relation?) {should be_true}
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rest_model-0.3.1 spec/unit/key/relation_spec.rb
rest_model-0.3.0 spec/unit/key/relation_spec.rb
rest_model-0.2.3 spec/unit/key/relation_spec.rb