Sha256: 3dda74f7553798af2eeb344ba5d0b09dbffbb75f71d574f8438b4f50ca5e1015
Contents?: true
Size: 1.42 KB
Versions: 10
Compression:
Stored size: 1.42 KB
Contents
describe Hubspot::Owner do let(:example_owners) do VCR.use_cassette('owner_example') do headers = { Authorization: "Bearer #{ENV.fetch('HUBSPOT_ACCESS_TOKEN')}" } HTTParty.get('https://api.hubapi.com/owners/v2/owners', headers: headers).parsed_response end end describe '.all' do cassette 'owner_all' it 'should find all owners' do owners = Hubspot::Owner.all expect(owners.blank?).to be false compare_owners(owners, example_owners) end end describe '.find_by_email' do cassette 'owner_find_by_email' let(:sample) { example_owners.first } let(:email) { sample['email'] } it 'should find a user via their email address' do owner = Hubspot::Owner.find_by_email(email) sample.map do |key, val| expect(owner[key]).to eq(val) end end end describe '.find_by_emails' do cassette 'owner_find_by_emails' let(:samples) { example_owners[0..[example_owners.count, 3].min] } let(:emails) { samples.map { |s| s['email'] } } it 'should find users via their email address' do owners = Hubspot::Owner.find_by_emails(emails) compare_owners(owners, samples) end end end def compare_owners(owners, examples) owners.each do |owner| example = examples.detect { |o| o['email'] == owner.email } expect(example.blank?).to be false example.each do |key, val| expect(owner[key]).to eq(val) end end end
Version data entries
10 entries across 10 versions & 1 rubygems