Sha256: 58bde7b225b8180d78167c1c0ade0d753e20e9ce5f77da76d8baa1b6b7ae6966

Contents?: true

Size: 1.69 KB

Versions: 1

Compression:

Stored size: 1.69 KB

Contents

require "spec_helper"

describe Redbooth::Me, vcr: 'me' do
  include_context 'authentication'
  let(:me) { client.me(:show) }
  let(:response) { double(:response, data: {})}

  describe '#initialize' do
    subject { me }

    it { expect(subject.email).to eql('example_frank@redbooth.com') }
    it { expect(subject.id).to eql(1) }
    it { expect(subject.first_name).to eql('Frank') }
    it { expect(subject.last_name).to eql('Kramer') }
  end

  describe '.show' do
    subject { me }

    it 'makes a new GET request using the correct API endpoint to receive a specific user' do
      expect(Redbooth).to receive(:request).with(:get, nil, 'me', {}, { session: session }).and_call_original
      subject
    end

    it { expect(subject.email).to eql('example_frank@redbooth.com') }
    it { expect(subject.id).to eql(1) }
    it { expect(subject.first_name).to eql('Frank') }
    it { expect(subject.last_name).to eql('Kramer') }
  end

  describe '#update' do
    let(:update_attributes) { { first_name: 'new_first_name' } }
    subject { client.me(:update, update_attributes) }

    it 'makes a new PUT request using the correct API endpoint' do
      expect(Redbooth).to receive(:request).with(:put, nil, 'me', update_attributes, { session: session }).and_return(response)
      subject
    end

    context 'integration' do
      after(:each) { client.me(:update, first_name: 'Frank') }

      it { expect(subject.first_name).to eql('new_first_name') }
    end
  end

  describe '#delete' do
    subject { client.me(:delete) }

    it 'makes a new DELETE request using the correct API endpoint' do
      expect(Redbooth).to receive(:request).with(:delete, nil, 'me', {}, { session: session })

      subject
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redbooth-ruby-0.0.2 spec/redbooth/me_spec.rb