Sha256: 4e1e6ddfba6bac904553640cbfe77c15ced7bf73038d51aac0b7cf832cf4d472

Contents?: true

Size: 915 Bytes

Versions: 24

Compression:

Stored size: 915 Bytes

Contents

require 'spec_helper'

describe ActiveRemote::PrimaryKey do
  let(:tag) { Tag.new(:id => '1234', :guid => 'TAG-123', :user_guid => 'USR-123') }

  after { Tag.instance_variable_set :@primary_key, nil }

  describe ".default_primary_key" do
    it 'returns array of :guid' do
      expect(Tag.default_primary_key).to eq(:guid)
    end
  end

  describe "primary_key" do
    context "when no arguments are passed" do
      it "returns default primary key" do
        expect(Tag.primary_key).to eq(:guid)
      end
    end

    context "when arguments are passed" do
      let(:specified_primary_key) { :name }

      it "returns the given primary key" do
        expect(Tag.primary_key(specified_primary_key)).to eq(specified_primary_key)
      end
    end
  end

  describe "#primary_key" do
    it "returns the primary key for the class" do
      expect(Tag.new.primary_key).to eq Tag.primary_key
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
active_remote-2.3.2 spec/lib/active_remote/primary_key_spec.rb
active_remote-2.3.1 spec/lib/active_remote/primary_key_spec.rb
active_remote-2.3.0 spec/lib/active_remote/primary_key_spec.rb
active_remote-2.2.0 spec/lib/active_remote/primary_key_spec.rb