ruby-lokalise-api 5.0.0 → 6.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +7 -5
  4. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/base_request.rb +4 -4
  5. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/client.rb +24 -24
  6. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/base.rb +10 -10
  7. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/branch.rb +1 -1
  8. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/contributor.rb +1 -1
  9. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/custom_translation_status.rb +1 -1
  10. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/file.rb +1 -1
  11. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/key.rb +2 -2
  12. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/key_comment.rb +1 -1
  13. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/order.rb +1 -1
  14. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/payment_card.rb +1 -1
  15. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/project.rb +1 -1
  16. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/project_comment.rb +1 -1
  17. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/project_language.rb +1 -1
  18. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/queued_process.rb +1 -1
  19. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/screenshot.rb +1 -1
  20. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/segment.rb +1 -1
  21. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/snapshot.rb +1 -1
  22. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/system_language.rb +1 -1
  23. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/task.rb +1 -1
  24. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/team.rb +1 -1
  25. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/team_user.rb +1 -1
  26. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/team_user_group.rb +1 -1
  27. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/translation.rb +1 -1
  28. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/translation_provider.rb +1 -1
  29. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/collections/webhook.rb +1 -1
  30. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/connection.rb +2 -2
  31. data/lib/ruby_lokalise_api/data/attributes.yml +235 -0
  32. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/error.rb +14 -14
  33. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/json_handler.rb +1 -1
  34. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/oauth2/auth.rb +2 -2
  35. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/oauth2/connection.rb +2 -2
  36. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/oauth2/request.rb +3 -3
  37. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/oauth2_client.rb +1 -1
  38. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/request.rb +3 -3
  39. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/base.rb +16 -8
  40. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/branch.rb +1 -1
  41. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/contributor.rb +1 -1
  42. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/custom_translation_status.rb +1 -1
  43. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/file.rb +2 -2
  44. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/key.rb +1 -1
  45. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/key_comment.rb +1 -1
  46. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/order.rb +1 -1
  47. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/payment_card.rb +1 -1
  48. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/project.rb +1 -1
  49. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/project_comment.rb +1 -1
  50. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/project_language.rb +1 -1
  51. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/queued_process.rb +1 -1
  52. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/screenshot.rb +1 -1
  53. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/segment.rb +1 -1
  54. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/snapshot.rb +2 -2
  55. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/system_language.rb +1 -1
  56. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/task.rb +1 -1
  57. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/team.rb +1 -1
  58. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/team_user.rb +1 -1
  59. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/team_user_billing_details.rb +1 -1
  60. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/team_user_group.rb +1 -1
  61. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/translation.rb +1 -1
  62. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/translation_provider.rb +1 -1
  63. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/resources/webhook.rb +1 -1
  64. data/lib/ruby_lokalise_api/rest/branches.rb +69 -0
  65. data/lib/ruby_lokalise_api/rest/comments.rb +61 -0
  66. data/lib/ruby_lokalise_api/rest/contributors.rb +58 -0
  67. data/lib/ruby_lokalise_api/rest/custom_translation_statuses.rb +67 -0
  68. data/lib/ruby_lokalise_api/rest/files.rb +49 -0
  69. data/lib/ruby_lokalise_api/rest/keys.rb +79 -0
  70. data/lib/ruby_lokalise_api/rest/languages.rb +67 -0
  71. data/lib/ruby_lokalise_api/rest/orders.rb +37 -0
  72. data/lib/ruby_lokalise_api/rest/payment_cards.rb +43 -0
  73. data/lib/ruby_lokalise_api/rest/projects.rb +62 -0
  74. data/lib/ruby_lokalise_api/rest/queued_processes.rb +28 -0
  75. data/lib/ruby_lokalise_api/rest/screenshots.rb +58 -0
  76. data/lib/ruby_lokalise_api/rest/segments.rb +45 -0
  77. data/lib/ruby_lokalise_api/rest/snapshots.rb +47 -0
  78. data/lib/ruby_lokalise_api/rest/tasks.rb +58 -0
  79. data/lib/ruby_lokalise_api/rest/team_user_billing_details.rb +36 -0
  80. data/lib/ruby_lokalise_api/rest/team_user_groups.rb +109 -0
  81. data/lib/ruby_lokalise_api/rest/team_users.rb +48 -0
  82. data/lib/ruby_lokalise_api/rest/teams.rb +16 -0
  83. data/lib/ruby_lokalise_api/rest/translation_providers.rb +27 -0
  84. data/lib/ruby_lokalise_api/rest/translations.rb +39 -0
  85. data/lib/ruby_lokalise_api/rest/webhooks.rb +69 -0
  86. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/utils/attribute_helpers.rb +7 -7
  87. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/utils/endpoint_helpers.rb +1 -1
  88. data/lib/{ruby-lokalise-api → ruby_lokalise_api}/utils/string_utils.rb +1 -1
  89. data/lib/ruby_lokalise_api/version.rb +5 -0
  90. data/lib/ruby_lokalise_api.rb +50 -0
  91. data/ruby-lokalise-api.gemspec +8 -7
  92. metadata +125 -157
  93. data/lib/ruby-lokalise-api/data/attributes.json +0 -259
  94. data/lib/ruby-lokalise-api/rest/branches.rb +0 -67
  95. data/lib/ruby-lokalise-api/rest/comments.rb +0 -59
  96. data/lib/ruby-lokalise-api/rest/contributors.rb +0 -56
  97. data/lib/ruby-lokalise-api/rest/custom_translation_statuses.rb +0 -65
  98. data/lib/ruby-lokalise-api/rest/files.rb +0 -36
  99. data/lib/ruby-lokalise-api/rest/keys.rb +0 -77
  100. data/lib/ruby-lokalise-api/rest/languages.rb +0 -65
  101. data/lib/ruby-lokalise-api/rest/orders.rb +0 -35
  102. data/lib/ruby-lokalise-api/rest/payment_cards.rb +0 -41
  103. data/lib/ruby-lokalise-api/rest/projects.rb +0 -60
  104. data/lib/ruby-lokalise-api/rest/queued_processes.rb +0 -26
  105. data/lib/ruby-lokalise-api/rest/screenshots.rb +0 -56
  106. data/lib/ruby-lokalise-api/rest/segments.rb +0 -43
  107. data/lib/ruby-lokalise-api/rest/snapshots.rb +0 -45
  108. data/lib/ruby-lokalise-api/rest/tasks.rb +0 -56
  109. data/lib/ruby-lokalise-api/rest/team_user_billing_details.rb +0 -34
  110. data/lib/ruby-lokalise-api/rest/team_user_group.rb +0 -107
  111. data/lib/ruby-lokalise-api/rest/team_users.rb +0 -46
  112. data/lib/ruby-lokalise-api/rest/teams.rb +0 -14
  113. data/lib/ruby-lokalise-api/rest/translation_providers.rb +0 -25
  114. data/lib/ruby-lokalise-api/rest/translations.rb +0 -37
  115. data/lib/ruby-lokalise-api/rest/webhooks.rb +0 -67
  116. data/lib/ruby-lokalise-api/version.rb +0 -5
  117. data/lib/ruby-lokalise-api.rb +0 -111
  118. data/spec/lib/ruby-lokalise-api/connection_spec.rb +0 -68
  119. data/spec/lib/ruby-lokalise-api/custom_json_parser_spec.rb +0 -81
  120. data/spec/lib/ruby-lokalise-api/error_spec.rb +0 -41
  121. data/spec/lib/ruby-lokalise-api/oauth2/auth_spec.rb +0 -73
  122. data/spec/lib/ruby-lokalise-api/rest/branches_spec.rb +0 -140
  123. data/spec/lib/ruby-lokalise-api/rest/comments_spec.rb +0 -118
  124. data/spec/lib/ruby-lokalise-api/rest/contributors_spec.rb +0 -132
  125. data/spec/lib/ruby-lokalise-api/rest/custom_translation_statuses_spec.rb +0 -131
  126. data/spec/lib/ruby-lokalise-api/rest/files_spec.rb +0 -66
  127. data/spec/lib/ruby-lokalise-api/rest/keys_spec.rb +0 -199
  128. data/spec/lib/ruby-lokalise-api/rest/languages_spec.rb +0 -134
  129. data/spec/lib/ruby-lokalise-api/rest/orders_spec.rb +0 -113
  130. data/spec/lib/ruby-lokalise-api/rest/payment_cards_spec.rb +0 -92
  131. data/spec/lib/ruby-lokalise-api/rest/projects_spec.rb +0 -150
  132. data/spec/lib/ruby-lokalise-api/rest/queued_processes_spec.rb +0 -57
  133. data/spec/lib/ruby-lokalise-api/rest/screenshots_spec.rb +0 -127
  134. data/spec/lib/ruby-lokalise-api/rest/segments_spec.rb +0 -106
  135. data/spec/lib/ruby-lokalise-api/rest/snapshots_spec.rb +0 -117
  136. data/spec/lib/ruby-lokalise-api/rest/tasks_spec.rb +0 -145
  137. data/spec/lib/ruby-lokalise-api/rest/team_user_billing_details_spec.rb +0 -48
  138. data/spec/lib/ruby-lokalise-api/rest/team_user_groups_spec.rb +0 -278
  139. data/spec/lib/ruby-lokalise-api/rest/team_users_spec.rb +0 -95
  140. data/spec/lib/ruby-lokalise-api/rest/teams_spec.rb +0 -25
  141. data/spec/lib/ruby-lokalise-api/rest/translation_providers_spec.rb +0 -48
  142. data/spec/lib/ruby-lokalise-api/rest/translations_spec.rb +0 -118
  143. data/spec/lib/ruby-lokalise-api/rest/webhooks_spec.rb +0 -126
  144. data/spec/lib/ruby-lokalise-api_spec.rb +0 -47
  145. data/spec/spec_helper.rb +0 -22
  146. data/spec/support/test_client.rb +0 -15
  147. data/spec/support/vcr.rb +0 -15
@@ -1,118 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Lokalise::Client do
4
- let(:project_id) { '803826145ba90b42d5d860.46800099' }
5
- let(:translation_id) { 80_015_147 }
6
- let(:another_translation_id) { 82_070_312 }
7
-
8
- describe '#translations' do
9
- it 'returns all translations' do
10
- translations = VCR.use_cassette('translations') do
11
- test_client.translations project_id
12
- end.collection
13
-
14
- expect(translations.count).to eq(9)
15
- end
16
-
17
- it 'supports pagination' do
18
- translations = VCR.use_cassette('all_translations_pagination') do
19
- test_client.translations project_id, limit: 4, page: 2, disable_references: 0,
20
- filter_is_reviewed: 0
21
- end
22
-
23
- expect(translations.collection.count).to eq(4)
24
- expect(translations.total_results).to eq(187)
25
- expect(translations.total_pages).to eq(47)
26
- expect(translations.results_per_page).to eq(4)
27
- expect(translations.current_page).to eq(2)
28
- expect(translations.request_params[:page]).to eq(2)
29
- expect(translations.request_params[:disable_references]).to eq(0)
30
- expect(translations.request_params[:filter_is_reviewed]).to eq(0)
31
-
32
- next_page_trans = VCR.use_cassette('translations_next_page') do
33
- translations.next_page
34
- end
35
-
36
- expect(next_page_trans).to be_an_instance_of(Lokalise::Collections::Translation)
37
- expect(next_page_trans.client).to be_an_instance_of(described_class)
38
- expect(next_page_trans.request_params[:page]).to eq(3)
39
- expect(next_page_trans.request_params[:disable_references]).to eq(0)
40
- expect(next_page_trans.total_results).to eq(187)
41
- expect(next_page_trans.current_page).to eq(3)
42
- expect(next_page_trans.next_page?).to eq(true)
43
- expect(next_page_trans.prev_page?).to eq(true)
44
-
45
- prev_page_trans = VCR.use_cassette('translations_prev_page') do
46
- translations.prev_page
47
- end
48
-
49
- expect(prev_page_trans).to be_an_instance_of(Lokalise::Collections::Translation)
50
- expect(prev_page_trans.client).to be_an_instance_of(described_class)
51
- expect(prev_page_trans.request_params[:page]).to eq(1)
52
- expect(next_page_trans.request_params[:disable_references]).to eq(0)
53
- expect(prev_page_trans.total_results).to eq(187)
54
- expect(prev_page_trans.current_page).to eq(1)
55
- expect(prev_page_trans.next_page?).to eq(true)
56
- expect(prev_page_trans.prev_page?).to eq(false)
57
- end
58
- end
59
-
60
- specify '#translation' do
61
- translation = VCR.use_cassette('translation') do
62
- test_client.translation project_id, 304_581_218
63
- end
64
-
65
- expect(translation.translation_id).to eq(304_581_218)
66
- expect(translation.key_id).to eq(44_596_059)
67
- expect(translation.language_iso).to eq('ru')
68
- expect(translation.modified_at).to eq('2020-05-15 10:44:42 (Etc/UTC)')
69
- expect(translation.modified_at_timestamp).to eq(1_589_539_482)
70
- expect(translation.modified_by).to eq(20_181)
71
- expect(translation.modified_by_email).to eq('bodrovis@protonmail.com')
72
- expect(translation.translation).to eq('Сообщение')
73
- expect(translation.is_fuzzy).to eq(false)
74
- expect(translation.is_reviewed).to eq(false)
75
- expect(translation.words).to eq(1)
76
- expect(translation.custom_translation_statuses).to eq([])
77
- expect(translation.task_id).to be_nil
78
- end
79
-
80
- specify '#reload_data' do
81
- translation = VCR.use_cassette('translation') do
82
- test_client.translation project_id, 304_581_218
83
- end
84
-
85
- reloaded_translation = VCR.use_cassette('translation') do
86
- translation.reload_data
87
- end
88
-
89
- expect(reloaded_translation.translation_id).to eq(translation.translation_id)
90
- end
91
-
92
- specify '#update_translation' do
93
- translation = VCR.use_cassette('update_translation') do
94
- test_client.update_translation project_id, translation_id, translation: 'rspec trans',
95
- is_reviewed: true
96
- end
97
-
98
- expect(translation.translation_id).to eq(translation_id)
99
- expect(translation.translation).to eq('rspec trans')
100
- expect(translation.is_reviewed).to eq(true)
101
- end
102
-
103
- context 'when translation chained methods are used' do
104
- it 'supports update' do
105
- translation = VCR.use_cassette('another_translation') do
106
- test_client.translation project_id, another_translation_id
107
- end
108
-
109
- updated_translation = VCR.use_cassette('update_translation_chained') do
110
- translation.update translation: 'chained updated'
111
- end
112
-
113
- expect(updated_translation.client.token).to eq(test_client.token)
114
- expect(updated_translation.translation).to eq('chained updated')
115
- expect(updated_translation.translation_id).to eq(translation.translation_id)
116
- end
117
- end
118
- end
@@ -1,126 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Lokalise::Client do
4
- let(:project_id) { '803826145ba90b42d5d860.46800099' }
5
- let(:webhook_id) { 'c7eb7e6e3c2fb2b26d0b64d0de083a5a71675b3d' }
6
- let(:new_webhook_id) { 'b345ccc6499920c490e8f4fe9487b1378dbf1dbf' }
7
- let(:serious_webhook_id) { '795565582e5ab15a59bb68156c7e2e9eaa1e8d1a' }
8
-
9
- describe '#webhooks' do
10
- it 'returns all webhooks' do
11
- webhooks = VCR.use_cassette('webhooks') do
12
- test_client.webhooks project_id
13
- end.collection
14
-
15
- expect(webhooks.count).to eq(3)
16
- expect(webhooks.first.url).to eq('https://serios.webhook')
17
- end
18
-
19
- it 'supports pagination' do
20
- webhooks = VCR.use_cassette('all_webhooks_pagination') do
21
- test_client.webhooks project_id, limit: 1, page: 2
22
- end
23
-
24
- expect(webhooks.collection.count).to eq(1)
25
- expect(webhooks.total_results).to eq(3)
26
- expect(webhooks.total_pages).to eq(3)
27
- expect(webhooks.results_per_page).to eq(1)
28
- expect(webhooks.current_page).to eq(2)
29
- end
30
- end
31
-
32
- specify '#webhook' do
33
- webhook = VCR.use_cassette('webhook') do
34
- test_client.webhook project_id, webhook_id
35
- end
36
-
37
- expect(webhook.webhook_id).to eq(webhook_id)
38
- expect(webhook.url).to eq('https://canihaz.hook')
39
- expect(webhook.secret).to eq('a62450cd9eeca8dfc84f3c0cf9b7a6a370267d6f')
40
- expect(webhook.events).to include('project.snapshot')
41
- expect(webhook.event_lang_map.first['event']).to eq('project.translation.updated')
42
- end
43
-
44
- specify '#reload_data' do
45
- webhook = VCR.use_cassette('webhook') do
46
- test_client.webhook project_id, webhook_id
47
- end
48
-
49
- reloaded_webhook = VCR.use_cassette('webhook') do
50
- webhook.reload_data
51
- end
52
-
53
- expect(reloaded_webhook.webhook_id).to eq(webhook.webhook_id)
54
- end
55
-
56
- specify '#create_webhook' do
57
- webhook = VCR.use_cassette('create_webhook') do
58
- test_client.create_webhook project_id,
59
- url: 'http://thatz.ahook',
60
- events: ['project.imported', 'project.exported']
61
- end
62
-
63
- expect(webhook.webhook_id).to eq(new_webhook_id)
64
- expect(webhook.url).to eq('http://thatz.ahook')
65
- expect(webhook.events).to include('project.imported', 'project.exported')
66
- end
67
-
68
- specify '#update_webhook' do
69
- webhook = VCR.use_cassette('update_webhook') do
70
- test_client.update_webhook project_id,
71
- new_webhook_id,
72
- url: 'http://ihaz.cheezburger'
73
- end
74
-
75
- expect(webhook.webhook_id).to eq(new_webhook_id)
76
- expect(webhook.url).to eq('http://ihaz.cheezburger')
77
- expect(webhook.events).to include('project.imported', 'project.exported')
78
- end
79
-
80
- specify '#destroy_webhook' do
81
- response = VCR.use_cassette('destroy_webhook') do
82
- test_client.destroy_webhook project_id,
83
- new_webhook_id
84
- end
85
-
86
- expect(response['project_id']).to eq(project_id)
87
- expect(response['webhook_deleted']).to eq(true)
88
- end
89
-
90
- specify '#regenerate_webhook_secret' do
91
- response = VCR.use_cassette('regenerate_webhook_secret') do
92
- test_client.regenerate_webhook_secret project_id,
93
- serious_webhook_id
94
- end
95
-
96
- expect(response['project_id']).to eq(project_id)
97
- expect(response['secret']).not_to be_nil
98
- end
99
-
100
- context 'when webhook chained methods are used' do
101
- it 'supports regenerate_webhook_secret' do
102
- webhook = VCR.use_cassette('webhook_2') do
103
- test_client.webhook project_id, serious_webhook_id
104
- end
105
-
106
- expect(webhook.branch).to eq('master')
107
- expect(webhook.webhook_id).to eq(serious_webhook_id)
108
-
109
- response = VCR.use_cassette('regenerate_webhook_secret_2') do
110
- webhook.regenerate_secret
111
- end
112
-
113
- expect(response['project_id']).to eq(project_id)
114
- expect(response['secret']).not_to be_nil
115
- end
116
-
117
- it 'supports update and destroy' do
118
- webhook = VCR.use_cassette('webhook_2') do
119
- test_client.webhook project_id, serious_webhook_id
120
- end
121
-
122
- expect(webhook).to respond_to(:update)
123
- expect(webhook).to respond_to(:destroy)
124
- end
125
- end
126
- end
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Lokalise do
4
- specify '.client' do
5
- expect(test_client).to be_an_instance_of(Lokalise::Client)
6
- expect(test_client.token).to eq(ENV['LOKALISE_API_TOKEN'])
7
- expect(test_client.timeout).to be_nil
8
- expect(test_client.open_timeout).to be_nil
9
- end
10
-
11
- specify '.reset_client!' do
12
- expect(test_client).to be_an_instance_of(Lokalise::Client)
13
- described_class.reset_client!
14
- current_client = described_class.instance_variable_get :@client
15
- expect(current_client).to be_nil
16
- end
17
-
18
- specify '.oauth2_client' do
19
- expect(test_oauth2_client).to be_an_instance_of(Lokalise::OAuth2Client)
20
- expect(test_oauth2_client.token).to eq("Bearer #{ENV['OAUTH2_TOKEN']}")
21
- expect(test_oauth2_client.timeout).to be_nil
22
- expect(test_oauth2_client.open_timeout).to be_nil
23
- end
24
-
25
- specify '.reset_oauth2_client!' do
26
- expect(test_oauth2_client).to be_an_instance_of(Lokalise::OAuth2Client)
27
- described_class.reset_oauth2_client!
28
- current_oauth_client = described_class.instance_variable_get :@oauth2_client
29
- expect(current_oauth_client).to be_nil
30
- end
31
-
32
- context 'with client params' do
33
- before { described_class.reset_client! }
34
-
35
- after { described_class.reset_client! }
36
-
37
- it 'is possible to customize timeout' do
38
- custom_client = described_class.client(ENV['LOKALISE_API_TOKEN'], timeout: 600)
39
- expect(custom_client.timeout).to eq(600)
40
- end
41
-
42
- it 'is possible to customize open timeout' do
43
- custom_client = described_class.client(ENV['LOKALISE_API_TOKEN'], open_timeout: 100)
44
- expect(custom_client.open_timeout).to eq(100)
45
- end
46
- end
47
- end
data/spec/spec_helper.rb DELETED
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'dotenv/load'
4
- require 'simplecov'
5
- SimpleCov.start do
6
- add_filter 'spec/'
7
- add_filter '.github/'
8
- end
9
-
10
- if ENV['CI'] == 'true'
11
- require 'codecov'
12
- SimpleCov.formatter = SimpleCov::Formatter::Codecov
13
- end
14
-
15
- require 'ruby-lokalise-api'
16
-
17
- # Support files
18
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f }
19
-
20
- RSpec.configure do |config|
21
- config.include TestClient
22
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module TestClient
4
- def test_client(token = nil, params = {})
5
- Lokalise.client(token || ENV['LOKALISE_API_TOKEN'], params)
6
- end
7
-
8
- def test_oauth2_client(token = nil, params = {})
9
- Lokalise.oauth2_client(token || ENV['OAUTH2_TOKEN'], params)
10
- end
11
-
12
- def auth_client
13
- Lokalise.auth_client(ENV['OAUTH2_CLIENT_ID'], ENV['OAUTH2_CLIENT_SECRET'])
14
- end
15
- end
data/spec/support/vcr.rb DELETED
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'vcr'
4
-
5
- VCR.configure do |c|
6
- c.ignore_hosts 'codeclimate.com'
7
- c.hook_into :faraday
8
- c.cassette_library_dir = File.join(File.dirname(__FILE__), '..', 'fixtures', 'vcr_cassettes')
9
- c.filter_sensitive_data('<LOKALISE_TOKEN>') { ENV.fetch('LOKALISE_API_TOKEN') }
10
- c.filter_sensitive_data('<OAUTH2_CLIENT_ID>') { ENV.fetch('OAUTH2_CLIENT_ID') }
11
- c.filter_sensitive_data('<OAUTH2_CLIENT_SECRET>') { ENV.fetch('OAUTH2_CLIENT_SECRET') }
12
- c.filter_sensitive_data('<OAUTH2_TOKEN>') { ENV.fetch('OAUTH2_TOKEN') }
13
- c.filter_sensitive_data('<OAUTH2_CODE>') { ENV.fetch('OAUTH2_CODE') }
14
- c.filter_sensitive_data('<OAUTH2_REFRESH_TOKEN>') { ENV.fetch('OAUTH2_REFRESH_TOKEN') }
15
- end