forked from ably/ably-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth_details_spec.rb
49 lines (38 loc) · 1.48 KB
/
auth_details_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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