Sha256: 15e12aac524c0f5da9bcb0c08f14d1cee110bf914a204af2e040fce92654982e

Contents?: true

Size: 1.48 KB

Versions: 45

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'
require 'shared/model_behaviour'

describe Ably::Models::AuthDetails do
  include Ably::Modules::Conversions

  subject { Ably::Models::AuthDetails }

  # Spec model items AD2*
  it_behaves_like 'a model', with_simple_attributes: %w(access_token) do
    let(:model_args) { [] }
  end

  context '==' do
    let(:attributes) { { access_token: 'unique' } }

    it 'is true when attributes are the same' do
      auth_details = -> { Ably::Models::AuthDetails.new(attributes) }
      expect(auth_details.call).to eq(auth_details.call)
    end

    it 'is false when attributes are not the same' do
      expect(Ably::Models::AuthDetails.new(access_token: '1')).to_not eq(Ably::Models::AuthDetails.new(access_token: '2'))
    end

    it 'is false when class type differs' do
      expect(Ably::Models::AuthDetails.new(access_token: '1')).to_not eq(nil)
    end
  end

  context 'AuthDetails conversion methods', :api_private do
    context 'with a AuthDetails object' do
      let(:details) { Ably::Models::AuthDetails.new(access_token: random_str) }

      it 'returns the AuthDetails object' do
        expect(Ably::Models::AuthDetails(details)).to eql(details)
      end
    end

    context 'with a JSON object' do
      let(:access_token) { random_str }
      let(:details_json) { { access_token: access_token } }

      it 'returns a new AuthDetails object from the JSON' do
        expect(Ably::Models::AuthDetails(details_json).access_token).to eql(access_token)
      end
    end
  end
end

Version data entries

45 entries across 45 versions & 2 rubygems

Version Path
ably-rest-1.2.7 lib/submodules/ably-ruby/spec/unit/models/auth_details_spec.rb
ably-1.2.7 spec/unit/models/auth_details_spec.rb
ably-rest-1.2.6 lib/submodules/ably-ruby/spec/unit/models/auth_details_spec.rb
ably-1.2.6 spec/unit/models/auth_details_spec.rb
ably-rest-1.2.4 lib/submodules/ably-ruby/spec/unit/models/auth_details_spec.rb
ably-1.2.4 spec/unit/models/auth_details_spec.rb
ably-rest-1.2.3 lib/submodules/ably-ruby/spec/unit/models/auth_details_spec.rb
ably-1.2.3 spec/unit/models/auth_details_spec.rb
ably-rest-1.2.2 lib/submodules/ably-ruby/spec/unit/models/auth_details_spec.rb
ably-1.2.2 spec/unit/models/auth_details_spec.rb
ably-rest-1.2.1 lib/submodules/ably-ruby/spec/unit/models/auth_details_spec.rb
ably-1.2.1 spec/unit/models/auth_details_spec.rb
ably-rest-1.2.0 lib/submodules/ably-ruby/spec/unit/models/auth_details_spec.rb
ably-1.2.0 spec/unit/models/auth_details_spec.rb
ably-rest-1.1.8 lib/submodules/ably-ruby/spec/unit/models/auth_details_spec.rb
ably-1.1.8 spec/unit/models/auth_details_spec.rb
ably-rest-1.1.7 lib/submodules/ably-ruby/spec/unit/models/auth_details_spec.rb
ably-1.1.7 spec/unit/models/auth_details_spec.rb
ably-rest-1.1.6 lib/submodules/ably-ruby/spec/unit/models/auth_details_spec.rb
ably-1.1.6 spec/unit/models/auth_details_spec.rb