Sha256: 34e0a73793e67a5021a2e4bc06643ef356dce779e31b786faae3936116ab2d55

Contents?: true

Size: 1.37 KB

Versions: 18

Compression:

Stored size: 1.37 KB

Contents

require "spec_helper"

describe G5Updatable::ClientUpdater do
  let(:uid) { "http://example.com/uid" }
  let(:properties) { {uid:  uid,
                      urn:  "urn",
                      name: "Client Name", } }
  let(:g5_client) { G5FoundationClient::Client.new(properties) }

  let(:updater) { described_class.new(g5_client) }

  describe "#update" do
    subject { G5Updatable::Client.first }

    context "with no existing Client records" do
      before { updater.update }

      let(:name) { 'Client Name' }

      it "creates a Client" do
        expect(G5Updatable::Client.count).to eq(1)
      end

      it 'does not redact keys in properties' do
        expect(subject.properties.keys.collect(&:to_sym)).to eq(properties.keys)
      end

      its(:uid) { should eq(uid) }
      its(:urn) { should eq("urn") }
      its(:name) { should eq(name) }

      it 'sets name field so that consumers can easily sort by name' do
        subject
        expect(G5Updatable::Client.find_by_name(name)).to eq(subject)
      end
    end

    context "with an existing Client record" do
      before do
        FactoryGirl.create(:client, uid: uid, urn: "old")
        updater.update
      end

      it "does not create a new Client" do
        expect(G5Updatable::Client.count).to eq(1)
      end

      its(:urn) { should eq("urn") }
      its(:name) { should eq("Client Name") }
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
g5_updatable-0.10.1 spec/lib/g5_updatable/client_updater_spec.rb
g5_updatable-0.10.0 spec/lib/g5_updatable/client_updater_spec.rb
g5_updatable-0.9.0 spec/lib/g5_updatable/client_updater_spec.rb
g5_updatable-0.8.0 spec/lib/g5_updatable/client_updater_spec.rb
g5_updatable-0.7.2 spec/lib/g5_updatable/client_updater_spec.rb
g5_updatable-0.7.1 spec/lib/g5_updatable/client_updater_spec.rb
g5_updatable-0.7.0 spec/lib/g5_updatable/client_updater_spec.rb
g5_updatable-0.6.1 spec/lib/g5_updatable/client_updater_spec.rb
g5_updatable-0.6.0 spec/lib/g5_updatable/client_updater_spec.rb
g5_updatable-0.5.1 spec/lib/g5_updatable/client_updater_spec.rb
g5_updatable-0.5.0 spec/lib/g5_updatable/client_updater_spec.rb
g5_updatable-0.4.3 spec/lib/g5_updatable/client_updater_spec.rb
g5_updatable-0.4.2 spec/lib/g5_updatable/client_updater_spec.rb
g5_updatable-0.4.1 spec/lib/g5_updatable/client_updater_spec.rb
g5_updatable-0.4.0 spec/lib/g5_updatable/client_updater_spec.rb
g5_updatable-0.3.5 spec/lib/g5_updatable/client_updater_spec.rb
g5_updatable-0.3.4 spec/lib/g5_updatable/client_updater_spec.rb
g5_updatable-0.3.3 spec/lib/g5_updatable/client_updater_spec.rb