Sha256: 402b857413e47eb00ca1b3cc4ca62bdf9d75f860384f1af5272fb4e79f9af95d

Contents?: true

Size: 1.65 KB

Versions: 27

Compression:

Stored size: 1.65 KB

Contents

require 'spec_helper'

describe RestModel::Association do
  describe "#initialize" do
    context "class_name" do
      context "when class_name option is passed" do
        subject do
          RestModel::Association.new(:login, class_name: :some_class)
        end

        it "sets passed class_name" do
          subject.instance_variable_get("@class_name").should == "SomeClass"
        end
      end

      context "when class_name option is not passed" do
        subject {RestModel::Association.new(:login)}

        it "sets default class_name" do
          subject.instance_variable_get("@class_name").should == "Login"
        end
      end
    end

    context "many" do
      context "when many option is passed with true" do
        subject do
          RestModel::Association.new(:login, many: true)
        end

        it "returns false to one?" do
          subject.one?.should be_false
        end

        it "returns true to many?" do
          subject.many?.should be_true
        end
      end

      context "when many option is passed with false" do
        subject do
          RestModel::Association.new(:login, many: false)
        end

        it "returns true to one?" do
          subject.one?.should be_true
        end

        it "returns false to many?" do
          subject.many?.should be_false
        end
      end

      context "when many option is not passed" do
        subject do
          RestModel::Association.new(:login)
        end

        it "returns true to one?" do
          subject.one?.should be_true
        end

        it "returns false to many?" do
          subject.many?.should be_false
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

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