Skip to content

Commit c5bd39e

Browse files
isloated tests
1 parent 151b7ab commit c5bd39e

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

spec/client_spec.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,22 @@ def loop_times(times)
3232
{ id: 'legolas', name: 'Legolas', race: 'Elf', age: 500 }
3333
]
3434
@client.upsert_users(@fellowship_of_the_ring)
35-
@channel = @client.channel('team', channel_id: 'fellowship-of-the-ring',
35+
36+
# Create a new channel for chat max length for channel_id is 64 characters
37+
channel_id = 'fellowship-of-the-ring-chat-' + SecureRandom.alphanumeric(20)
38+
39+
@channel = @client.channel('team', channel_id: channel_id,
3640
data: { members: @fellowship_of_the_ring.map { |fellow| fellow[:id] } })
3741
@channel.create('gandalf')
3842
end
3943

4044
before(:each) do
41-
@random_users = [{ id: SecureRandom.uuid }, { id: SecureRandom.uuid }]
42-
@random_user = { id: SecureRandom.uuid }
43-
users_to_insert = [@random_users[0], @random_users[1], @random_user]
45+
@random_users = [{ id: SecureRandom.uuid }, { id: SecureRandom.uuid }, { id: SecureRandom.uuid }]
46+
@random_user = @random_users[0]
4447

45-
@created_users.push(*users_to_insert.map { |u| u[:id] })
48+
@created_users.push(*@random_users.map { |u| u[:id] })
4649

47-
@client.upsert_users(users_to_insert)
50+
@client.upsert_users(@random_users)
4851
end
4952

5053
after(:all) do
@@ -448,7 +451,7 @@ def loop_times(times)
448451
it 'queries channels' do
449452
response = @client.query_channels({ 'members' => { '$in' => ['legolas'] } }, sort: { 'id' => 1 })
450453
expect(response['channels'].length).to eq 1
451-
expect(response['channels'][0]['channel']['id']).to eq 'fellowship-of-the-ring'
454+
expect(response['channels'][0]['channel']['id']).to eq @channel.id
452455
expect(response['channels'][0]['members'].length).to eq 4
453456
end
454457

spec/moderation_spec.rb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,22 @@ def loop_times(times)
3232
{ id: 'legolas', name: 'Legolas', race: 'Elf', age: 500 }
3333
]
3434
@client.upsert_users(@fellowship_of_the_ring)
35-
@channel = @client.channel('team', channel_id: 'fellowship-of-the-ring',
35+
36+
# Create a new channel for moderation
37+
channel_id = 'fellowship-of-the-ring-moderation-' + SecureRandom.alphanumeric(20)
38+
39+
@channel = @client.channel('team', channel_id: channel_id,
3640
data: { members: @fellowship_of_the_ring.map { |fellow| fellow[:id] } })
3741
@channel.create('gandalf')
3842
end
3943

4044
before(:each) do
41-
@random_users = [{ id: SecureRandom.uuid }, { id: SecureRandom.uuid }]
42-
@random_user = { id: SecureRandom.uuid }
43-
users_to_insert = [@random_users[0], @random_users[1], @random_user]
45+
@random_users = [{ id: SecureRandom.uuid }, { id: SecureRandom.uuid }, { id: SecureRandom.uuid }]
46+
@random_user = @random_users[0]
4447

45-
@created_users.push(*users_to_insert.map { |u| u[:id] })
48+
@created_users.push(*@random_users.map { |u| u[:id] })
4649

47-
@client.upsert_users(users_to_insert)
50+
@client.upsert_users(@random_users)
4851
end
4952

5053
after(:all) do

0 commit comments

Comments
 (0)