Sha256: cb56a5d732f74e5a5351ac0c2ba31c7288580a0af19ad158c7472f3159981491
Contents?: true
Size: 1.33 KB
Versions: 4
Compression:
Stored size: 1.33 KB
Contents
require "helper" module Dovico describe Dovico::Employee do let(:employee_api_hash) do { "ID": "123", "FirstName": "James", "LastName": "Bond", }.stringify_keys end subject do Dovico::Employee.parse(employee_api_hash) 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 describe '#to_s' do it 'returns object with formatted text' do expect(subject.to_s).to eq(" - ID: 123\n - First Name: James\n - Last Name: Bond") end end end end
Version data entries
4 entries across 4 versions & 1 rubygems