forked from 7even/vkontakte_api
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathintegration_spec.rb
62 lines (53 loc) · 1.52 KB
/
integration_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
50
51
52
53
54
55
56
57
58
59
60
61
62
# encoding: utf-8
require 'spec_helper'
describe "Integration" do
before(:all) do
VkontakteApi.register_alias
# turn off all the logging
VK.configure do |config|
config.log_requests = false
config.log_errors = false
config.log_responses = false
config.api_version = '5.0'
end
end
if MechanizedAuthorization.on?
let(:vk) { MechanizedAuthorization.client }
describe "authorized requests" do
it "get groups" do
expect(vk.groups.get.items).to include(1)
end
end
describe "requests with camelCase and predicate methods" do
it "convert method names to vk.com format" do
expect(vk.is_app_user?).to be_truthy
end
end
describe "requests with array arguments" do
it "join arrays with a comma" do
users = vk.users.get(uids: [1, 2, 3], fields: %w[first_name last_name screen_name])
expect(users.first.screen_name).not_to be_empty
end
end
describe "requests with blocks" do
it "map the result with a block" do
users = vk.users.get(uid: 1) do |user|
"#{user.last_name} #{user.first_name}"
end
expect(users.first).not_to be_empty
end
end
end
describe "authorization" do
context "with a scope" do
it "returns a correct url" do
url = VK.authorization_url(scope: %w[friends groups])
expect(url).to include('scope=friends%2Cgroups')
end
end
end
after(:all) do
VK.reset
VK.unregister_alias
end
end