Sha256: 9023e1eb0492a50e34d419507c131cc5bb89c445f74cd0616bc828fb690c5866

Contents?: true

Size: 1.71 KB

Versions: 3

Compression:

Stored size: 1.71 KB

Contents

require "spec_helper"

describe RedboothRuby::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(RedboothRuby).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(RedboothRuby).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(RedboothRuby).to receive(:request).with(:delete, nil, 'me', {}, { session: session })

      subject
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
redbooth-ruby-0.0.5 spec/redbooth-ruby/me_spec.rb
redbooth-ruby-0.0.4 spec/redbooth-ruby/me_spec.rb
redbooth-ruby-0.0.3 spec/redbooth-ruby/me_spec.rb