transifex-interface-ruby 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +6 -14
- data/.gitignore +17 -17
- data/.rspec +2 -0
- data/Gemfile +4 -4
- data/LICENSE.txt +22 -22
- data/README.md +517 -513
- data/Rakefile +1 -1
- data/lib/transifex.rb +84 -87
- data/lib/transifex/crud_requests.rb +43 -33
- data/lib/transifex/errors.rb +4 -4
- data/lib/transifex/project_components/language.rb +1 -1
- data/lib/transifex/project_components/language_components/coordinators.rb +4 -6
- data/lib/transifex/project_components/language_components/reviewers.rb +5 -8
- data/lib/transifex/project_components/language_components/translators.rb +6 -9
- data/lib/transifex/project_components/languages.rb +1 -1
- data/lib/transifex/resource.rb +1 -1
- data/lib/transifex/resource_components/content.rb +1 -1
- data/lib/transifex/resource_components/source.rb +1 -1
- data/lib/transifex/resource_components/stats.rb +1 -1
- data/lib/transifex/resource_components/translation.rb +1 -1
- data/lib/transifex/resource_components/translation_components/string.rb +1 -1
- data/lib/transifex/resource_components/translation_components/strings.rb +1 -1
- data/lib/transifex/resources.rb +1 -1
- data/lib/transifex/version.rb +3 -3
- data/spec/cassettes/fetch_formats.yml +121 -0
- data/spec/cassettes/language/fetch_language_info.yml +58 -0
- data/spec/cassettes/language/fetch_languages_info.yml +58 -0
- data/spec/cassettes/project/components/create_language.yml +95 -0
- data/spec/cassettes/project/components/create_language_non_existing_coordinator.yml +48 -0
- data/spec/cassettes/project/components/create_language_without_coordinator.yml +48 -0
- data/spec/cassettes/project/components/fetch_languages.yml +53 -0
- data/spec/cassettes/project/delete_project.yml +108 -0
- data/spec/cassettes/project/fetch_private_project_info.yml +59 -0
- data/spec/cassettes/project/fetch_with_details_private_project_info.yml +66 -0
- data/spec/cassettes/project/language/delete_language.yml +140 -0
- data/spec/cassettes/project/language/fetch_coordinators.yml +56 -0
- data/spec/cassettes/project/language/fetch_language_info.yml +52 -0
- data/spec/cassettes/project/language/fetch_reviewers.yml +56 -0
- data/spec/cassettes/project/language/fetch_translators.yml +54 -0
- data/spec/cassettes/project/language/fetch_with_details_language_info.yml +54 -0
- data/spec/cassettes/project/language/update_coordinators.yml +104 -0
- data/spec/cassettes/project/language/update_language.yml +100 -0
- data/spec/cassettes/project/language/update_non_existing_coordinator.yml +48 -0
- data/spec/cassettes/project/language/update_non_existing_language.yml +49 -0
- data/spec/cassettes/project/language/update_non_existing_reviewer.yml +101 -0
- data/spec/cassettes/project/language/update_non_existing_translator.yml +101 -0
- data/spec/cassettes/project/language/update_reviewers.yml +157 -0
- data/spec/cassettes/project/language/update_translators.yml +157 -0
- data/spec/cassettes/project/update_non_existing_attribute_private_project.yml +54 -0
- data/spec/cassettes/project/update_private_project.yml +120 -0
- data/spec/cassettes/project/update_with_missing_params_private_project.yml +54 -0
- data/spec/cassettes/projects/create_private_project.yml +111 -0
- data/spec/cassettes/projects/create_public_project.yml +111 -0
- data/spec/cassettes/projects/create_used_slug_project.yml +55 -0
- data/spec/cassettes/projects/fetch_projects.yml +61 -0
- data/spec/cassettes/resource/delete_not_existing_resource.yml +55 -0
- data/spec/cassettes/resource/delete_resource.yml +160 -0
- data/spec/cassettes/resource/fetch_all_languages_stats.yml +66 -0
- data/spec/cassettes/resource/fetch_content_as_file.yml +56 -0
- data/spec/cassettes/resource/fetch_content_as_hash.yml +58 -0
- data/spec/cassettes/resource/fetch_language_stats.yml +61 -0
- data/spec/cassettes/resource/fetch_not_existing_resource.yml +55 -0
- data/spec/cassettes/resource/fetch_resource_info.yml +59 -0
- data/spec/cassettes/resource/fetch_source_string_metadata.yml +52 -0
- data/spec/cassettes/resource/fetch_translations.yml +57 -0
- data/spec/cassettes/resource/fetch_updated_resource_info.yml +60 -0
- data/spec/cassettes/resource/fetch_updated_source_string_metadata.yml +52 -0
- data/spec/cassettes/resource/fetch_with_details_resource_info.yml +65 -0
- data/spec/cassettes/resource/fetch_with_file_and_mode_translations.yml +56 -0
- data/spec/cassettes/resource/fetch_with_file_translations.yml +56 -0
- data/spec/cassettes/resource/update_content_json.yml +115 -0
- data/spec/cassettes/resource/update_content_with_wrong_mimetype.yml +59 -0
- data/spec/cassettes/resource/update_content_yml.yml +114 -0
- data/spec/cassettes/resource/update_not_existing_resource.yml +55 -0
- data/spec/cassettes/resource/update_resource_info.yml +114 -0
- data/spec/cassettes/resource/update_source_language.yml +54 -0
- data/spec/cassettes/resource/update_source_string_metadata.yml +100 -0
- data/spec/cassettes/resource/update_translation_for_language.yml +62 -0
- data/spec/cassettes/resources/create_from_file.yml +55 -0
- data/spec/cassettes/resources/create_from_string.yml +54 -0
- data/spec/cassettes/resources/fetch_as_array.yml +62 -0
- data/spec/cassettes/resources/non_existing_project.yml +55 -0
- data/spec/cassettes/translation/fetch_string.yml +55 -0
- data/spec/cassettes/translation/fetch_strings.yml +54 -0
- data/spec/cassettes/translation/fetch_with_details_and_context_strings.yml +51 -0
- data/spec/cassettes/translation/fetch_with_details_and_key_strings.yml +56 -0
- data/spec/cassettes/translation/fetch_with_details_strings.yml +56 -0
- data/spec/cassettes/translation/update_multiple_translation_strings.yml +107 -0
- data/spec/cassettes/translation/update_single_translation_strings.yml +104 -0
- data/spec/cassettes/translation/update_string.yml +104 -0
- data/spec/lib/transifex/coordinators_spec.rb +22 -16
- data/spec/lib/transifex/formats_spec.rb +8 -8
- data/spec/lib/transifex/language_spec.rb +9 -10
- data/spec/lib/transifex/languages_spec.rb +8 -8
- data/spec/lib/transifex/project_language_spec.rb +41 -28
- data/spec/lib/transifex/project_languages_spec.rb +34 -18
- data/spec/lib/transifex/project_spec.rb +46 -73
- data/spec/lib/transifex/projects_spec.rb +72 -37
- data/spec/lib/transifex/resource_content_spec.rb +41 -24
- data/spec/lib/transifex/resource_source_spec.rb +21 -19
- data/spec/lib/transifex/resource_spec.rb +69 -41
- data/spec/lib/transifex/resources_spec.rb +42 -34
- data/spec/lib/transifex/reviewers_spec.rb +23 -17
- data/spec/lib/transifex/stats_spec.rb +20 -24
- data/spec/lib/transifex/translation_spec.rb +60 -38
- data/spec/lib/transifex/translation_string_spec.rb +26 -20
- data/spec/lib/transifex/translation_strings_spec.rb +65 -43
- data/spec/lib/transifex/translators_spec.rb +23 -17
- data/spec/lib/transifex_spec.rb +15 -0
- data/spec/lib/yaml/eo.yml +3 -0
- data/spec/spec_helper.rb +19 -83
- data/spec/support/client_helper.rb +8 -0
- data/spec/support/content_helper.rb +346 -0
- data/transifex-interface-ruby.gemspec +28 -25
- metadata +198 -21
- data/spec/lib/transifex/configuration_spec.rb +0 -17
- data/spec/lib/yaml/resource_translation_default_content_test.yml +0 -4
- data/spec/lib/yaml/resource_translation_reviewed_content_test.yml +0 -9
@@ -0,0 +1,104 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: put
|
5
|
+
uri: http://www.transifex.com/api/2/project/ruby-client/resource/test/translation/en/strings
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '[{"key":"test_string","translation":"updated translation","source_entity_hash":"1dc9aad7928cb3cb1b400d17d39a8523"}]'
|
9
|
+
headers:
|
10
|
+
Content-Type:
|
11
|
+
- application/json
|
12
|
+
Accept:
|
13
|
+
- application/json
|
14
|
+
User-Agent:
|
15
|
+
- Transifex-interface-ruby/0.0.1
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
Authorization:
|
19
|
+
- Basic bS5naWFtYml0dG9AZnJlZWdvd2ViLml0Om1vbGxpXzAx
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Server:
|
26
|
+
- nginx
|
27
|
+
Vary:
|
28
|
+
- Accept-Encoding
|
29
|
+
- Authorization, Host, Accept-Language, Cookie
|
30
|
+
Content-Type:
|
31
|
+
- text/plain
|
32
|
+
Date:
|
33
|
+
- Thu, 04 May 2017 13:55:33 GMT
|
34
|
+
Transfer-Encoding:
|
35
|
+
- chunked
|
36
|
+
Content-Language:
|
37
|
+
- en
|
38
|
+
X-Content-Type-Options:
|
39
|
+
- nosniff
|
40
|
+
Connection:
|
41
|
+
- keep-alive
|
42
|
+
Set-Cookie:
|
43
|
+
- X-Mapping-fjhppofk=A44BEC4CD0B51682CDC2AA3E9CCFDDF4; path=/
|
44
|
+
X-Frame-Options:
|
45
|
+
- SAMEORIGIN
|
46
|
+
body:
|
47
|
+
encoding: ASCII-8BIT
|
48
|
+
string: OK
|
49
|
+
http_version:
|
50
|
+
recorded_at: Thu, 04 May 2017 13:55:34 GMT
|
51
|
+
- request:
|
52
|
+
method: get
|
53
|
+
uri: http://www.transifex.com/api/2/project/ruby-client/resource/test/translation/en/string/1dc9aad7928cb3cb1b400d17d39a8523
|
54
|
+
body:
|
55
|
+
encoding: UTF-8
|
56
|
+
string: "{}"
|
57
|
+
headers:
|
58
|
+
Content-Type:
|
59
|
+
- application/json
|
60
|
+
Accept:
|
61
|
+
- application/json
|
62
|
+
User-Agent:
|
63
|
+
- Transifex-interface-ruby/0.0.1
|
64
|
+
Accept-Encoding:
|
65
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
66
|
+
Authorization:
|
67
|
+
- Basic bS5naWFtYml0dG9AZnJlZWdvd2ViLml0Om1vbGxpXzAx
|
68
|
+
response:
|
69
|
+
status:
|
70
|
+
code: 200
|
71
|
+
message: OK
|
72
|
+
headers:
|
73
|
+
Server:
|
74
|
+
- nginx
|
75
|
+
Vary:
|
76
|
+
- Accept-Encoding
|
77
|
+
- Authorization, Host, Accept-Language, Cookie
|
78
|
+
Content-Type:
|
79
|
+
- application/json; charset=utf-8
|
80
|
+
Date:
|
81
|
+
- Thu, 04 May 2017 13:55:34 GMT
|
82
|
+
Transfer-Encoding:
|
83
|
+
- chunked
|
84
|
+
Content-Language:
|
85
|
+
- en
|
86
|
+
X-Content-Type-Options:
|
87
|
+
- nosniff
|
88
|
+
Connection:
|
89
|
+
- keep-alive
|
90
|
+
Set-Cookie:
|
91
|
+
- X-Mapping-fjhppofk=100E7CB61F7D5C274279F09EADF920A3; path=/
|
92
|
+
X-Frame-Options:
|
93
|
+
- SAMEORIGIN
|
94
|
+
body:
|
95
|
+
encoding: ASCII-8BIT
|
96
|
+
string: "{\n \"comment\": \"\", \n \"context\": \"\", \n \"tags\":
|
97
|
+
null, \n \"character_limit\": null, \n \"reviewed\": false, \n \"user\":
|
98
|
+
\"nirnaeth\", \n \"key\": \"test_string\", \n \"source_string\": \"test
|
99
|
+
string\", \n \"translation\": \"updated translation\", \n \"last_update\":
|
100
|
+
\"2017-05-04T13:52:15.278\", \n \"pluralized\": false, \n \"occurrences\":
|
101
|
+
null\n}"
|
102
|
+
http_version:
|
103
|
+
recorded_at: Thu, 04 May 2017 13:55:34 GMT
|
104
|
+
recorded_with: VCR 3.0.3
|
@@ -0,0 +1,104 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: put
|
5
|
+
uri: http://www.transifex.com/api/2/project/ruby-client/resource/test/translation/en/string/1dc9aad7928cb3cb1b400d17d39a8523
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"reviewed":true,"translation":"translated test string"}'
|
9
|
+
headers:
|
10
|
+
Content-Type:
|
11
|
+
- application/json
|
12
|
+
Accept:
|
13
|
+
- application/json
|
14
|
+
User-Agent:
|
15
|
+
- Transifex-interface-ruby/0.0.1
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
Authorization:
|
19
|
+
- Basic bS5naWFtYml0dG9AZnJlZWdvd2ViLml0Om1vbGxpXzAx
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Server:
|
26
|
+
- nginx
|
27
|
+
Vary:
|
28
|
+
- Accept-Encoding
|
29
|
+
- Authorization, Host, Accept-Language, Cookie
|
30
|
+
Content-Type:
|
31
|
+
- text/plain
|
32
|
+
Date:
|
33
|
+
- Thu, 04 May 2017 12:24:03 GMT
|
34
|
+
Transfer-Encoding:
|
35
|
+
- chunked
|
36
|
+
Content-Language:
|
37
|
+
- en
|
38
|
+
X-Content-Type-Options:
|
39
|
+
- nosniff
|
40
|
+
Connection:
|
41
|
+
- keep-alive
|
42
|
+
Set-Cookie:
|
43
|
+
- X-Mapping-fjhppofk=300CA58EE011BC6BC0E393EE4F2B31F6; path=/
|
44
|
+
X-Frame-Options:
|
45
|
+
- SAMEORIGIN
|
46
|
+
body:
|
47
|
+
encoding: ASCII-8BIT
|
48
|
+
string: OK
|
49
|
+
http_version:
|
50
|
+
recorded_at: Thu, 04 May 2017 12:24:04 GMT
|
51
|
+
- request:
|
52
|
+
method: get
|
53
|
+
uri: http://www.transifex.com/api/2/project/ruby-client/resource/test/translation/en/string/1dc9aad7928cb3cb1b400d17d39a8523
|
54
|
+
body:
|
55
|
+
encoding: UTF-8
|
56
|
+
string: "{}"
|
57
|
+
headers:
|
58
|
+
Content-Type:
|
59
|
+
- application/json
|
60
|
+
Accept:
|
61
|
+
- application/json
|
62
|
+
User-Agent:
|
63
|
+
- Transifex-interface-ruby/0.0.1
|
64
|
+
Accept-Encoding:
|
65
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
66
|
+
Authorization:
|
67
|
+
- Basic bS5naWFtYml0dG9AZnJlZWdvd2ViLml0Om1vbGxpXzAx
|
68
|
+
response:
|
69
|
+
status:
|
70
|
+
code: 200
|
71
|
+
message: OK
|
72
|
+
headers:
|
73
|
+
Server:
|
74
|
+
- nginx
|
75
|
+
Vary:
|
76
|
+
- Accept-Encoding
|
77
|
+
- Authorization, Host, Accept-Language, Cookie
|
78
|
+
Content-Type:
|
79
|
+
- application/json; charset=utf-8
|
80
|
+
Date:
|
81
|
+
- Thu, 04 May 2017 12:24:04 GMT
|
82
|
+
Transfer-Encoding:
|
83
|
+
- chunked
|
84
|
+
Content-Language:
|
85
|
+
- en
|
86
|
+
X-Content-Type-Options:
|
87
|
+
- nosniff
|
88
|
+
Connection:
|
89
|
+
- keep-alive
|
90
|
+
Set-Cookie:
|
91
|
+
- X-Mapping-fjhppofk=371E5B112B2394FA3017E8BE0809059C; path=/
|
92
|
+
X-Frame-Options:
|
93
|
+
- SAMEORIGIN
|
94
|
+
body:
|
95
|
+
encoding: ASCII-8BIT
|
96
|
+
string: "{\n \"comment\": \"\", \n \"context\": \"\", \n \"tags\":
|
97
|
+
null, \n \"character_limit\": null, \n \"reviewed\": true, \n \"user\":
|
98
|
+
\"nirnaeth\", \n \"key\": \"test_string\", \n \"source_string\": \"test
|
99
|
+
string\", \n \"translation\": \"translated test string\", \n \"last_update\":
|
100
|
+
\"2017-05-04T12:22:46.171\", \n \"pluralized\": false, \n \"occurrences\":
|
101
|
+
null\n}"
|
102
|
+
http_version:
|
103
|
+
recorded_at: Thu, 04 May 2017 12:24:04 GMT
|
104
|
+
recorded_with: VCR 3.0.3
|
@@ -1,32 +1,38 @@
|
|
1
|
-
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Transifex::ProjectComponents::LanguageComponents::Coordinators do
|
4
|
-
|
5
|
-
@project = Transifex::Project.new("projet-de-test-1")
|
6
|
-
end
|
4
|
+
let(:project) { Transifex::Project.new("ruby-client") }
|
7
5
|
|
8
|
-
describe "
|
9
|
-
it "should raise an error
|
10
|
-
expect{ Transifex::ProjectComponents::LanguageComponents::Coordinators.new }
|
6
|
+
describe "Instantiation" do
|
7
|
+
it "should raise an error if the project_slug is not provided" do
|
8
|
+
expect { Transifex::ProjectComponents::LanguageComponents::Coordinators.new }
|
9
|
+
.to raise_error(Transifex::MissingParametersError)
|
10
|
+
.with_message("The following attributes are missing: project_slug")
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "Fetch" do
|
15
|
-
it "should
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
expect(language_coordinators_infos.keys).to contain_exactly("coordinators")
|
15
|
+
it "should retrieve the language coordinators" do
|
16
|
+
VCR.use_cassette "project/language/fetch_coordinators" do
|
17
|
+
expect(project.language("en").coordinators.fetch).to eq({"coordinators"=>["wirido"]})
|
18
|
+
end
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
23
22
|
describe "Update" do
|
24
|
-
it "
|
25
|
-
|
23
|
+
it "overwrites the coordinators list" do
|
24
|
+
VCR.use_cassette "project/language/update_coordinators" do
|
25
|
+
expect(project.language("en").coordinators.update(["nirnaeth"])).to eq "OK"
|
26
|
+
expect(project.language("en").coordinators.fetch).to eq({"coordinators"=>["nirnaeth"]})
|
27
|
+
end
|
26
28
|
end
|
27
29
|
|
28
30
|
it "should raise an error if the coordinator doesn't exist" do
|
29
|
-
|
31
|
+
VCR.use_cassette "project/language/update_non_existing_coordinator" do
|
32
|
+
expect { project.language("en").coordinators.update(["not_existing_coordinator"]) }
|
33
|
+
.to raise_error(Transifex::TransifexError)
|
34
|
+
.with_message("Users not_existing_coordinator do not exist.")
|
35
|
+
end
|
30
36
|
end
|
31
37
|
end
|
32
|
-
end
|
38
|
+
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Transifex::Formats do
|
4
|
-
|
5
4
|
describe "Fetch" do
|
6
|
-
it "should fetch all formats
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
it "should fetch all formats allowed by Transifex" do
|
6
|
+
|
7
|
+
VCR.use_cassette "fetch_formats" do
|
8
|
+
formats = Transifex::Formats.fetch
|
9
|
+
expect(formats.keys).to include("KEYVALUEJSON", "YML", "TXT")
|
10
|
+
end
|
11
11
|
end
|
12
12
|
end
|
13
|
-
end
|
13
|
+
end
|
@@ -1,19 +1,18 @@
|
|
1
|
-
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Transifex::Language do
|
4
|
-
|
5
|
-
describe "instanciation" do
|
4
|
+
describe "Instantiation" do
|
6
5
|
it "should raise an error if a language code is not provided" do
|
7
6
|
expect { Transifex::Language.new }.to raise_error(Transifex::MissingParametersError)
|
7
|
+
.with_message("The following attributes are missing: language_code")
|
8
8
|
end
|
9
|
-
end
|
9
|
+
end
|
10
10
|
|
11
11
|
describe "Fetch" do
|
12
|
-
it "should fetch the selected language
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
expect(fetched_languages.keys).to contain_exactly("rtl", "pluralequation", "code", "name", "nplurals")
|
12
|
+
it "should fetch the selected language info" do
|
13
|
+
VCR.use_cassette "language/fetch_language_info" do
|
14
|
+
expect(Transifex::Languages.fetch("fr")).to eq(language_info)
|
15
|
+
end
|
17
16
|
end
|
18
17
|
end
|
19
|
-
end
|
18
|
+
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Transifex::Languages do
|
4
|
-
|
5
4
|
describe "Fetch" do
|
6
|
-
it "should fetch all languages
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
it "should fetch information aviyt all languages" do
|
6
|
+
VCR.use_cassette "language/fetch_languages_info" do
|
7
|
+
info = Transifex::Languages.fetch
|
8
|
+
expect(info).to be_an Array
|
9
|
+
expect(info.first.keys).to eq(["rtl", "pluralequation", "code", "name", "nplurals"])
|
10
|
+
end
|
11
11
|
end
|
12
12
|
end
|
13
|
-
end
|
13
|
+
end
|
@@ -1,49 +1,62 @@
|
|
1
|
-
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Transifex::ProjectComponents::Language do
|
4
|
-
|
5
|
-
@project = Transifex::Project.new("projet-de-test-1")
|
6
|
-
end
|
4
|
+
let(:project) { Transifex::Project.new("ruby-client") }
|
7
5
|
|
8
|
-
describe "
|
9
|
-
it "should raise an error
|
10
|
-
expect{ Transifex::ProjectComponents::Language.new }.to raise_error(Transifex::MissingParametersError)
|
6
|
+
describe "Instantiation" do
|
7
|
+
it "should raise an error if the project_slug is not provided" do
|
8
|
+
expect { Transifex::ProjectComponents::Language.new }.to raise_error(Transifex::MissingParametersError)
|
9
|
+
.with_message("The following attributes are missing: project_slug")
|
11
10
|
end
|
12
11
|
end
|
13
12
|
|
14
13
|
describe "Fetch" do
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
describe "#fetch" do
|
15
|
+
it "should retrieve the basic info for the language" do
|
16
|
+
VCR.use_cassette "project/language/fetch_language_info" do
|
17
|
+
expect(project.language("en").fetch).to eq(basic_language_info)
|
18
|
+
end
|
19
|
+
end
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
describe "#fetch_with_details" do
|
23
|
+
it "retrieve the complete info for the language" do
|
24
|
+
VCR.use_cassette "project/language/fetch_with_details_language_info" do
|
25
|
+
expect(project.language("en").fetch_with_details).to eq(detailed_language_info)
|
26
|
+
end
|
27
|
+
end
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
30
31
|
describe "Update" do
|
31
|
-
it "should raise an error if language doesn't exist
|
32
|
-
|
32
|
+
it "should raise an error if the language doesn't exist" do
|
33
|
+
params = {coordinators: []}
|
34
|
+
|
35
|
+
VCR.use_cassette "project/language/update_non_existing_language" do
|
36
|
+
expect { project.language("non_existing_language").update(params) }.to raise_error(Transifex::TransifexError)
|
37
|
+
.with_message("Not Found")
|
38
|
+
end
|
33
39
|
end
|
34
40
|
|
35
|
-
it "should
|
36
|
-
|
41
|
+
it "should update the language info" do
|
42
|
+
params = {"coordinators" => ["nirnaeth"], "translators" => [], "reviewers" => ["wirido"]}
|
43
|
+
|
44
|
+
VCR.use_cassette "project/language/update_language" do
|
45
|
+
expect(project.language("en").update(params)).to eq "OK"
|
46
|
+
expect(project.language("en").fetch).to eq params
|
47
|
+
end
|
37
48
|
end
|
38
49
|
end
|
39
50
|
|
40
51
|
describe "Delete" do
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
52
|
+
it "should delete the language" do
|
53
|
+
VCR.use_cassette "project/language/delete_language" do
|
54
|
+
project.languages.create(language_code: "it", coordinators: ["wirido"])
|
55
|
+
|
56
|
+
expect(project.language("it").delete).to be nil
|
57
|
+
expect { project.language("it").fetch }.to raise_error(Transifex::TransifexError)
|
58
|
+
.with_message("Forbidden")
|
59
|
+
end
|
47
60
|
end
|
48
61
|
end
|
49
|
-
end
|
62
|
+
end
|
@@ -1,35 +1,51 @@
|
|
1
|
-
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Transifex::ProjectComponents::Languages do
|
4
|
-
|
5
|
-
@project = Transifex::Project.new("projet-de-test-1")
|
6
|
-
end
|
4
|
+
let(:project) { Transifex::Project.new("ruby-client") }
|
7
5
|
|
8
|
-
describe "
|
9
|
-
it "should raise an error
|
10
|
-
expect{ Transifex::ProjectComponents::Languages.new }
|
6
|
+
describe "Instantiation" do
|
7
|
+
it "should raise an error if the project_slug is not provided" do
|
8
|
+
expect { Transifex::ProjectComponents::Languages.new }
|
9
|
+
.to raise_error(Transifex::MissingParametersError)
|
10
|
+
.with_message("The following attributes are missing: project_slug")
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "Fetch" do
|
15
|
-
it "should
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
expect(project_languages.first.keys).to contain_exactly("coordinators", "language_code", "translators", "reviewers")
|
15
|
+
it "should retrieve the information for all languages of the project" do
|
16
|
+
VCR.use_cassette "project/components/fetch_languages" do
|
17
|
+
expect(project.languages.fetch).to eq(project_languages_info)
|
18
|
+
end
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
23
22
|
describe "Create" do
|
24
|
-
it "should
|
25
|
-
|
23
|
+
it "should create a new language for the project" do
|
24
|
+
params = {language_code: "fr", coordinators: ["wirido"]}
|
25
|
+
|
26
|
+
VCR.use_cassette "project/components/create_language" do
|
27
|
+
expect(project.languages.create(params)).to eq("Created")
|
28
|
+
|
29
|
+
project.language("fr").delete
|
30
|
+
end
|
26
31
|
end
|
32
|
+
|
27
33
|
it "should raise an error if the coordinator doesn't exist" do
|
28
|
-
|
34
|
+
params = {language_code: "fr", coordinators: ["non_existing"]}
|
35
|
+
|
36
|
+
VCR.use_cassette "project/components/create_language_non_existing_coordinator" do
|
37
|
+
expect { project.languages.create(params) }.to raise_error(Transifex::TransifexError)
|
38
|
+
.with_message("Users non_existing do not exist.")
|
39
|
+
end
|
29
40
|
end
|
30
41
|
|
31
|
-
|
32
|
-
|
42
|
+
it "should raise an error if no coordinator is provided" do
|
43
|
+
params = {language_code: "fr", coordinators: []}
|
44
|
+
|
45
|
+
VCR.use_cassette "project/components/create_language_without_coordinator" do
|
46
|
+
expect { project.languages.create(params) }.to raise_error(Transifex::TransifexError)
|
47
|
+
.with_message("There must be a coordinator set for a language.")
|
48
|
+
end
|
33
49
|
end
|
34
50
|
end
|
35
|
-
end
|
51
|
+
end
|