Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix Ruby SDK
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexander Olofsson
Matrix Ruby SDK
Commits
b8bbfc59
Verified
Commit
b8bbfc59
authored
1 year ago
by
Alexander Olofsson
Browse files
Options
Downloads
Patches
Plain Diff
Continue webmock conversion
parent
0bbbe869
No related branches found
No related tags found
No related merge requests found
Pipeline
#102684
failed
1 year ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/api_cs_protocol_test.rb
+16
-17
16 additions, 17 deletions
test/api_cs_protocol_test.rb
test/room_test.rb
+6
-6
6 additions, 6 deletions
test/room_test.rb
with
22 additions
and
23 deletions
test/api_cs_protocol_test.rb
+
16
−
17
View file @
b8bbfc59
...
...
@@ -17,7 +17,7 @@ class ApiTest < Test::Unit::TestCase
end
def
stub_versions_request
stub_request
(
:get
,
'/_matrix/client/versions'
).
to_return_json
(
stub_request
(
:get
,
'
https://example.com
/_matrix/client/versions'
).
to_return_json
(
body:
{
versions:
[
"r0.0.1"
,
"r0.1.0"
,
"r0.2.0"
,
"r0.3.0"
,
"r0.4.0"
,
"r0.5.0"
,
"r0.6.0"
,
"r0.6.1"
,
"v1.1"
,
"v1.2"
,
"v1.3"
,
"v1.4"
,
"v1.5"
,
"v1.6"
],
unstable_features:
{
...
...
@@ -50,7 +50,7 @@ class ApiTest < Test::Unit::TestCase
def
test_api_versions
stub_versions_request
assert_equal
'
r0.4.0
'
,
@api
.
client_api_versions
.
latest
assert_equal
'
v1.6
'
,
@api
.
client_api_versions
.
latest
end
def
test_api_unsable_features
...
...
@@ -59,38 +59,37 @@ class ApiTest < Test::Unit::TestCase
end
def
test_whoami
stub_get
=
stub_request
(
:get
,
'/_matrix/client/
v3
/account/whoami'
).
to_return_json
(
stub_request
(
:get
,
'
https://example.com
/_matrix/client/
r0
/account/whoami'
).
to_return_json
(
body:
{
user_id:
'@user:example.com'
,
device_id:
'SZXMMIIRVP'
,
is_guest:
false
}
)
assert_equal
@api
.
whoami?
,
user_id:
'@user:example.com'
assert_requested
stub_get
assert_equal
'@user:example.com'
,
@api
.
whoami?
[
:user_id
]
end
def
test_sync
@http
.
expects
(
:request
).
with
do
|
req
|
req
.
path
==
'/_matrix/client/r0/sync?timeout=30000'
end
.
returns
(
mock_success
(
'{}'
))
stub_request
(
:get
,
'https://example.com/_matrix/client/r0/sync'
).
with
(
query:
{
timeout:
30000
}).
to_return_json
(
body:
{})
assert
@api
.
sync
end
def
test_sync_timeout
@http
.
expects
(
:request
).
with
do
|
req
|
req
.
path
==
'/_matrix/client/r0/sync?timeout=3000'
end
.
returns
(
mock_success
(
'{}'
))
stub_request
(
:get
,
'https://example.com/_matrix/client/r0/sync'
).
with
(
query:
{
timeout:
3000
}).
to_return_json
(
body:
{})
assert
@api
.
sync
(
timeout:
3
)
@http
.
expects
(
:request
).
with
do
|
req
|
req
.
path
==
'/_matrix/client/r0/sync'
end
.
returns
(
mock_success
(
'{}'
))
stub_request
(
:get
,
'https://example.com/_matrix/client/r0/sync'
).
with
(
query:
nil
).
to_return_json
(
body:
{})
assert
@api
.
sync
(
timeout:
nil
)
end
def
test_send_message
@api
.
expects
(
:request
).
with
(
:put
,
:client_r0
,
'/rooms/%21room%3Aexample.com/send/m.room.message/42'
,
body:
{
msgtype:
'm.text'
,
body:
'this is a message'
},
query:
{}).
returns
({})
stub_request
(
:put
,
'https://example.com/_matrix/client/r0/rooms/%21room%3Aexample.com/send/m.room.message/42'
).
with
(
body:
{
msgtype:
'm.text'
,
body:
'this is a message'
}
).
to_return_json
(
body:
{})
assert
@api
.
send_message
(
'!room:example.com'
,
'this is a message'
,
txn_id:
42
)
end
...
...
This diff is collapsed.
Click to expand it.
test/room_test.rb
+
6
−
6
View file @
b8bbfc59
...
...
@@ -115,7 +115,7 @@ class RoomTest < Test::Unit::TestCase
@api
.
expects
(
:send_message
).
with
(
@id
,
text
)
@room
.
send_text
(
text
)
@api
.
expects
(
:send_message_event
).
with
(
@id
,
'm.room.message'
,
body:
'test'
,
msgtype:
'm.text'
,
formatted_body:
text
,
format:
'org.matrix.custom.html'
)
@api
.
expects
(
:send_message_event
).
with
(
@id
,
'm.room.message'
,
{
body:
'test'
,
msgtype:
'm.text'
,
formatted_body:
text
,
format:
'org.matrix.custom.html'
}
)
@room
.
send_html
(
text
)
@api
.
expects
(
:send_emote
).
with
(
@id
,
text
)
...
...
@@ -161,17 +161,17 @@ class RoomTest < Test::Unit::TestCase
@api
.
expects
(
:get_room_account_data
).
with
(
'@alice:example.com'
,
@id
,
'com.example.Test'
)
@room
.
get_account_data
(
'com.example.Test'
)
@api
.
expects
(
:set_room_account_data
).
with
(
'@alice:example.com'
,
@id
,
'com.example.Test'
,
data:
true
)
@api
.
expects
(
:set_room_account_data
).
with
(
'@alice:example.com'
,
@id
,
'com.example.Test'
,
{
data:
true
}
)
@room
.
set_account_data
(
'com.example.Test'
,
data:
true
)
@api
.
expects
(
:get_membership
).
with
(
@id
,
'@alice:example.com'
).
returns
(
membership:
'join'
)
@api
.
expects
(
:set_membership
).
with
(
@id
,
'@alice:example.com'
,
'join'
,
'Updating room profile information'
,
membership:
'join'
,
displayname:
'Alice'
,
avatar_url:
'mxc://example.com/avatar'
)
@api
.
expects
(
:set_membership
).
with
(
@id
,
'@alice:example.com'
,
'join'
,
'Updating room profile information'
,
{
membership:
'join'
,
displayname:
'Alice'
,
avatar_url:
'mxc://example.com/avatar'
}
)
@room
.
set_user_profile
display_name:
'Alice'
,
avatar_url:
'mxc://example.com/avatar'
@api
.
expects
(
:get_user_tags
).
with
(
'@alice:example.com'
,
@id
).
returns
(
tags:
{
'example.tag'
:
{}
})
tags
=
@room
.
tags
@api
.
expects
(
:add_user_tag
).
with
(
'@alice:example.com'
,
@id
,
:'test.tag'
,
data:
true
)
@api
.
expects
(
:add_user_tag
).
with
(
'@alice:example.com'
,
@id
,
:'test.tag'
,
{
data:
true
}
)
tags
.
add
'test.tag'
,
data:
true
@api
.
expects
(
:remove_user_tag
).
with
(
'@alice:example.com'
,
@id
,
:'test.tag'
)
...
...
@@ -280,11 +280,11 @@ class RoomTest < Test::Unit::TestCase
def
test_modifies
@api
.
expects
(
:get_room_state
).
with
(
@id
,
'm.room.power_levels'
).
returns
users_default:
0
,
redact:
50
@api
.
expects
(
:set_room_state
).
with
(
@id
,
'm.room.power_levels'
,
users_default:
5
,
redact:
50
,
users:
{
'@alice:example.com'
:
100
})
@api
.
expects
(
:set_room_state
).
with
(
@id
,
'm.room.power_levels'
,
{
users_default:
5
,
redact:
50
,
users:
{
'@alice:example.com'
:
100
}
})
@room
.
modify_user_power_levels
({
'@alice:example.com'
:
100
},
5
)
@api
.
expects
(
:get_room_state
).
with
(
@id
,
'm.room.power_levels'
).
returns
users_default:
0
,
redact:
50
@api
.
expects
(
:set_room_state
).
with
(
@id
,
'm.room.power_levels'
,
users_default:
0
,
redact:
50
,
events:
{
'm.room.message'
:
100
})
@api
.
expects
(
:set_room_state
).
with
(
@id
,
'm.room.power_levels'
,
{
users_default:
0
,
redact:
50
,
events:
{
'm.room.message'
:
100
}
})
@room
.
modify_required_power_levels
'm.room.message'
:
100
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment