Sha256: c5a07f8d9993fccb8fa307c92ccf49d4cf5cd347cd913942e497dd04360a91a3

Contents?: true

Size: 1.14 KB

Versions: 18

Compression:

Stored size: 1.14 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

18 entries across 18 versions & 1 rubygems

Version Path
active_remote-6.0.3 spec/lib/active_remote/scope_keys_spec.rb
active_remote-6.1.2 spec/lib/active_remote/scope_keys_spec.rb
active_remote-7.0.0 spec/lib/active_remote/scope_keys_spec.rb
active_remote-6.1.1 spec/lib/active_remote/scope_keys_spec.rb
active_remote-6.1.0 spec/lib/active_remote/scope_keys_spec.rb
active_remote-6.0.2 spec/lib/active_remote/scope_keys_spec.rb
active_remote-6.0.1 spec/lib/active_remote/scope_keys_spec.rb
active_remote-6.0.0.beta spec/lib/active_remote/scope_keys_spec.rb
active_remote-5.2.0 spec/lib/active_remote/scope_keys_spec.rb
active_remote-5.2.0.beta spec/lib/active_remote/scope_keys_spec.rb
active_remote-5.2.0.alpha spec/lib/active_remote/scope_keys_spec.rb
active_remote-5.0.1 spec/lib/active_remote/scope_keys_spec.rb
active_remote-5.1.1 spec/lib/active_remote/scope_keys_spec.rb
active_remote-5.1.0 spec/lib/active_remote/scope_keys_spec.rb
active_remote-5.0.0 spec/lib/active_remote/scope_keys_spec.rb
active_remote-5.1.0.rc1 spec/lib/active_remote/scope_keys_spec.rb
active_remote-5.0.0.rc1 spec/lib/active_remote/scope_keys_spec.rb
active_remote-5.0.0.pre spec/lib/active_remote/scope_keys_spec.rb