Sha256: 5315d5e5d5ddb34d31610279eace9c141a75149eeb8550c48c29f944c3c245ea

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

require "helper"

module Dovico
  describe Dovico::Employee do
    let(:employee_api_hash) do
      {
        "ID": "123",
        "FirstName": "James",
        "LastName": "Bond",
      }.stringify_keys
    end

    describe ".parse" do
      it "parses the hash" do
        employee = Dovico::Employee.parse(employee_api_hash)

        expect(employee).to be_an(Dovico::Employee)
        expect(employee.id).to eq('123')
        expect(employee.first_name).to eq('James')
        expect(employee.last_name).to eq('Bond')
      end
    end

    describe ".myself" do
      let(:employee_me_answer) do
        {
          "Employees": [ employee_api_hash ]
        }.stringify_keys
      end

      before do
        allow(ApiClient).to receive(:get).and_return(employee_me_answer)
      end

      it 'calls the API and return an Employee object' do
        myself = Dovico::Employee.myself

        expect(ApiClient).to have_received(:get).with("#{Dovico::Employee::URL_PATH}/Me")
        expect(myself).to be_an(Dovico::Employee)
        expect(myself.id).to eq('123')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dovico-1.0.0 spec/unit/dovico/model/employee_spec.rb