Sha256: 2550e8ff663ff556f8be5c85b58718062d856fcf87ec96966c3441b85bbcc103

Contents?: true

Size: 1.15 KB

Versions: 23

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'

describe ActiveRemote::ScopeKeys do
  let(:key) { :user_guid }
  let(:_scope_keys) { [ 'user_guid' ] }
  let(:scope_keys) { [ 'guid' ] + _scope_keys }
  let(:tag) { Tag.new(tag_hash) }
  let(:tag_hash) { { :guid => 'TAG-123', :user_guid => 'USR-123', :name => 'teh tag' } }

  describe ".scope_key" do
    after { Tag._scope_keys = [] }

    it 'adds scope_key to _scope_keys' do
      Tag.scope_key(key)
      expect(Tag._scope_keys).to eq(_scope_keys)
    end
  end

  describe ".scope_keys" do
    before { allow(Tag).to receive(:_scope_keys).and_return(_scope_keys) }

    it "combines primary key with _scope_keys" do
      expect(Tag.scope_keys).to eq(['guid'] + _scope_keys)
    end
  end

  describe "#scope_keys" do
    it "returns the scope keys for the class" do
      expect(Tag.new.scope_keys).to eq Tag.scope_keys
    end
  end

  describe "#scope_key_hash" do
    let(:scope_key_hash) { { 'guid' => 'TAG-123', 'user_guid' => 'USR-123' } }

    before { allow(tag).to receive(:scope_keys).and_return(scope_keys) }

    it "returns a attribute hash of scope_keys" do
      expect(tag.scope_key_hash).to eq(scope_key_hash)
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
active_remote-3.3.3 spec/lib/active_remote/scope_keys_spec.rb
active_remote-3.3.2 spec/lib/active_remote/scope_keys_spec.rb
active_remote-3.3.1 spec/lib/active_remote/scope_keys_spec.rb
active_remote-3.3.0 spec/lib/active_remote/scope_keys_spec.rb
active_remote-3.2.2 spec/lib/active_remote/scope_keys_spec.rb
active_remote-3.2.1 spec/lib/active_remote/scope_keys_spec.rb
active_remote-3.2.0 spec/lib/active_remote/scope_keys_spec.rb
active_remote-3.2.0.pre spec/lib/active_remote/scope_keys_spec.rb
active_remote-3.1.3 spec/lib/active_remote/scope_keys_spec.rb
active_remote-3.1.2 spec/lib/active_remote/scope_keys_spec.rb
active_remote-3.1.2.pre spec/lib/active_remote/scope_keys_spec.rb
active_remote-3.1.1 spec/lib/active_remote/scope_keys_spec.rb
active_remote-3.1.0 spec/lib/active_remote/scope_keys_spec.rb
active_remote-3.0.0 spec/lib/active_remote/scope_keys_spec.rb
active_remote-3.0.0.pre1 spec/lib/active_remote/scope_keys_spec.rb
active_remote-2.4.0 spec/lib/active_remote/scope_keys_spec.rb
active_remote-2.3.5 spec/lib/active_remote/scope_keys_spec.rb
active_remote-2.3.4 spec/lib/active_remote/scope_keys_spec.rb
active_remote-2.3.3 spec/lib/active_remote/scope_keys_spec.rb
active_remote-2.3.3.pre spec/lib/active_remote/scope_keys_spec.rb