-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from sampatbadhe/improve_specs
Improve specs
- Loading branch information
Showing
17 changed files
with
249 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe Dotloop::Contact do | ||
let(:client) { Dotloop::Client.new(access_token: SecureRandom.uuid) } | ||
subject { Dotloop::Contact.new(client: client) } | ||
subject(:dotloop_contact) { Dotloop::Contact.new(client: client) } | ||
|
||
describe '#initialize' do | ||
it 'exist' do | ||
expect(subject).to_not be_nil | ||
expect(dotloop_contact).to_not be_nil | ||
end | ||
|
||
it 'set the client' do | ||
expect(subject.client).to eq(client) | ||
expect(dotloop_contact.client).to eq(client) | ||
end | ||
end | ||
|
||
describe '#all' do | ||
it 'return all contacts' do | ||
dotloop_mock_batch(:contacts) | ||
contacts = subject.all() | ||
contacts = dotloop_contact.all | ||
expect(contacts.size).to eq(52) | ||
expect(contacts).to all(be_a(Dotloop::Models::Contact)) | ||
end | ||
|
@@ -26,7 +28,7 @@ | |
describe '#find' do | ||
it 'return a contact' do | ||
dotloop_mock(:contact) | ||
contact = subject.find(contact_id: 3_603_862) | ||
contact = dotloop_contact.find(contact_id: 3_603_862) | ||
expect(contact).to be_a(Dotloop::Models::Contact) | ||
end | ||
end | ||
|
@@ -35,17 +37,17 @@ | |
it 'return a contact' do | ||
dotloop_mock(:contacts, :post, 201) | ||
params = { | ||
"firstName": "Brian", | ||
"lastName": "Erwin", | ||
"email": "[email protected]", | ||
"home": "(415) 8936 332", | ||
"office": "(415) 1213 656", | ||
"fax": "(415) 8655 686", | ||
"address": "2100 Waterview Dr", | ||
"city": "San Francisco", | ||
"zipCode": "94114", | ||
"state": "CA", | ||
"country": "US" | ||
"firstName": 'Brian', | ||
"lastName": 'Erwin', | ||
"email": '[email protected]', | ||
"home": '(415) 8936 332', | ||
"office": '(415) 1213 656', | ||
"fax": '(415) 8655 686', | ||
"address": '2100 Waterview Dr', | ||
"city": 'San Francisco', | ||
"zipCode": '94114', | ||
"state": 'CA', | ||
"country": 'US' | ||
} | ||
|
||
contact = subject.create(params: params) | ||
|
@@ -56,9 +58,9 @@ | |
describe '#update' do | ||
it 'return a contact' do | ||
dotloop_mock(:contact, :patch) | ||
contact = subject.update(contact_id: 3_603_862, params: { "home": "(415) 888 8888" }) | ||
contact = subject.update(contact_id: 3_603_862, params: { "home": '(415) 888 8888' }) | ||
expect(contact).to be_a(Dotloop::Models::Contact) | ||
expect(contact).to have_attributes(home: "(415) 888 8888") | ||
expect(contact).to have_attributes(home: '(415) 888 8888') | ||
end | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.