transifex-interface-ruby 0.0.1
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 +15 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +513 -0
- data/Rakefile +1 -0
- data/lib/transifex.rb +87 -0
- data/lib/transifex/crud_requests.rb +99 -0
- data/lib/transifex/errors.rb +25 -0
- data/lib/transifex/formats.rb +9 -0
- data/lib/transifex/json.rb +23 -0
- data/lib/transifex/language.rb +13 -0
- data/lib/transifex/languages.rb +13 -0
- data/lib/transifex/project.rb +38 -0
- data/lib/transifex/project_components/language.rb +39 -0
- data/lib/transifex/project_components/language_components/coordinators.rb +29 -0
- data/lib/transifex/project_components/language_components/reviewers.rb +33 -0
- data/lib/transifex/project_components/language_components/translators.rb +33 -0
- data/lib/transifex/project_components/languages.rb +21 -0
- data/lib/transifex/projects.rb +22 -0
- data/lib/transifex/resource.rb +41 -0
- data/lib/transifex/resource_components/content.rb +54 -0
- data/lib/transifex/resource_components/source.rb +23 -0
- data/lib/transifex/resource_components/stats.rb +26 -0
- data/lib/transifex/resource_components/translation.rb +59 -0
- data/lib/transifex/resource_components/translation_components/string.rb +29 -0
- data/lib/transifex/resource_components/translation_components/strings.rb +39 -0
- data/lib/transifex/resource_components/translation_components/utilities.rb +22 -0
- data/lib/transifex/resources.rb +19 -0
- data/lib/transifex/version.rb +3 -0
- data/spec/lib/transifex/configuration_spec.rb +17 -0
- data/spec/lib/transifex/coordinators_spec.rb +32 -0
- data/spec/lib/transifex/formats_spec.rb +13 -0
- data/spec/lib/transifex/language_spec.rb +19 -0
- data/spec/lib/transifex/languages_spec.rb +13 -0
- data/spec/lib/transifex/project_language_spec.rb +49 -0
- data/spec/lib/transifex/project_languages_spec.rb +35 -0
- data/spec/lib/transifex/project_spec.rb +91 -0
- data/spec/lib/transifex/projects_spec.rb +48 -0
- data/spec/lib/transifex/resource_content_spec.rb +40 -0
- data/spec/lib/transifex/resource_source_spec.rb +30 -0
- data/spec/lib/transifex/resource_spec.rb +66 -0
- data/spec/lib/transifex/resources_spec.rb +50 -0
- data/spec/lib/transifex/reviewers_spec.rb +32 -0
- data/spec/lib/transifex/stats_spec.rb +34 -0
- data/spec/lib/transifex/translation_spec.rb +53 -0
- data/spec/lib/transifex/translation_string_spec.rb +33 -0
- data/spec/lib/transifex/translation_strings_spec.rb +57 -0
- data/spec/lib/transifex/translators_spec.rb +32 -0
- data/spec/lib/yaml/en.yml +26 -0
- data/spec/lib/yaml/fr.yml +4 -0
- data/spec/lib/yaml/resource_content_test.yml +27 -0
- data/spec/lib/yaml/resource_translation_default_content_test.yml +4 -0
- data/spec/lib/yaml/resource_translation_reviewed_content_test.yml +9 -0
- data/spec/spec_helper.rb +96 -0
- data/transifex-interface-ruby.gemspec +25 -0
- metadata +181 -0
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe Transifex::Languages do
|
4
|
+
|
5
|
+
describe "Fetch" do
|
6
|
+
it "should fetch all languages infos without raising an error" do
|
7
|
+
fetched_languages = nil
|
8
|
+
expect{ fetched_languages = Transifex::Languages.fetch }.to_not raise_error
|
9
|
+
expect(fetched_languages).to be_a_kind_of(Array)
|
10
|
+
expect(fetched_languages.first.keys).to contain_exactly("rtl", "pluralequation", "code", "name", "nplurals")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe Transifex::ProjectComponents::Language do
|
4
|
+
before(:all) do
|
5
|
+
@project = Transifex::Project.new("projet-de-test-1")
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "Instanciation" do
|
9
|
+
it "should raise an error when no parameters given" do
|
10
|
+
expect{ Transifex::ProjectComponents::Language.new }.to raise_error(Transifex::MissingParametersError)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "Fetch" do
|
15
|
+
it "should not raise an error and retrieve the language's informations without details" do
|
16
|
+
project_language_infos = nil
|
17
|
+
expect{ project_language_infos = @project.language('en').fetch }.to_not raise_error
|
18
|
+
expect(project_language_infos).to be_a_kind_of(Hash)
|
19
|
+
expect(project_language_infos.keys).to contain_exactly("coordinators", "translators", "reviewers")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should not raise an error and retrieve the language's informations with details" do
|
23
|
+
project_language_infos = nil
|
24
|
+
expect{ project_language_infos = @project.language('en').fetch_with_details }.to_not raise_error
|
25
|
+
expect(project_language_infos).to be_a_kind_of(Hash)
|
26
|
+
expect(project_language_infos.keys).to contain_exactly("coordinators", "reviewers", "total_segments", "untranslated_segments", "translated_words", "reviewed_segments", "translators","translated_segments")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "Update" do
|
31
|
+
it "should raise an error if language doesn't exist " do
|
32
|
+
expect{ @project.language('dzdzadaz').update({:coordinators => ['fredericgrais'], :translators => ['fredericgrais'], :reviewers => ['fredericgrais']}) }.to raise_error(Transifex::TransifexError)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should not raise an error and update the language's infos " do
|
36
|
+
expect{ @project.language('fr').update({:coordinators => ['fredericgrais'], :translators => ['fredericgrais'], :reviewers => ['fredericgrais']}) }.to_not raise_error
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "Delete" do
|
41
|
+
before(:all) do
|
42
|
+
@project.languages.create({:language_code => "it", :coordinators => ['fredericgrais']})
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should delete the resource without raising an error" do
|
46
|
+
expect{ @project.language('it').delete }.to_not raise_error
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe Transifex::ProjectComponents::Languages do
|
4
|
+
before(:all) do
|
5
|
+
@project = Transifex::Project.new("projet-de-test-1")
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "Instanciation" do
|
9
|
+
it "should raise an error when no parameters given" do
|
10
|
+
expect{ Transifex::ProjectComponents::Languages.new }.to raise_error(Transifex::MissingParametersError)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "Fetch" do
|
15
|
+
it "should not raise an error and retrieve the languages informations" do
|
16
|
+
project_languages = nil
|
17
|
+
expect{ project_languages = @project.languages.fetch }.to_not raise_error
|
18
|
+
expect(project_languages).to be_a_kind_of(Array)
|
19
|
+
expect(project_languages.first.keys).to contain_exactly("coordinators", "language_code", "translators", "reviewers")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "Create" do
|
24
|
+
it "should not raise an error and create the new language for the project" do
|
25
|
+
expect{@project.languages.create({:language_code => "el", :coordinators => ['fredericgrais']}) }.to_not raise_error
|
26
|
+
end
|
27
|
+
it "should raise an error if the coordinator doesn't exist" do
|
28
|
+
expect{@project.languages.create({:language_code => "el", :coordinators => ['fredericgrais', 'loiloililoi']}) }.to raise_error(Transifex::TransifexError)
|
29
|
+
end
|
30
|
+
|
31
|
+
after(:all) do
|
32
|
+
@project.language('el').delete
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe Transifex::Project do
|
4
|
+
|
5
|
+
describe "Manage a project" do
|
6
|
+
before(:all) do
|
7
|
+
@correct_params_private = {:slug => "projet_private", :name => "Projet de test Private", :description => "description", :source_language_code => "en", :private => true}
|
8
|
+
@correct_params_public = {:slug => "projet_public", :name => "Projet de test Public", :description => "description", :source_language_code => "en", :repository_url => "http://en.google.com"}
|
9
|
+
@private_project = Transifex::Projects.create(@correct_params_private)
|
10
|
+
@public_project = Transifex::Projects.create(@correct_params_public)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "instanciation" do
|
14
|
+
it "should raise an error if a slug is not provided" do
|
15
|
+
expect { Transifex::Project.new }.to raise_error(Transifex::MissingParametersError)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "private project" do
|
20
|
+
describe "fetch" do
|
21
|
+
it "should retrieve informations about the project without details" do
|
22
|
+
fetched_project = @private_project.fetch
|
23
|
+
expect { fetched_project = @private_project.fetch }.to_not raise_error
|
24
|
+
expect(fetched_project).to be_a_kind_of(Hash)
|
25
|
+
expect(fetched_project.keys).to contain_exactly("slug", "name", "description","source_language_code")
|
26
|
+
end
|
27
|
+
it "should retrieve informations about the project with details" do
|
28
|
+
fetched_project = nil
|
29
|
+
expect { fetched_project = @private_project.fetch_with_details }.to_not raise_error
|
30
|
+
expect(fetched_project).to be_a_kind_of(Hash)
|
31
|
+
expect(fetched_project.keys).to contain_exactly("archived", "auto_join", "fill_up_resources", "homepage", "last_updated", "long_description", "maintainers", "organization", "private", "resources", "tags", "team", "teams", "trans_instructions", "slug", "name", "description","source_language_code")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
describe "update" do
|
35
|
+
it "should not raise an error and update the project" do
|
36
|
+
updated_project = nil
|
37
|
+
expect { updated_project = @private_project.update({:description => "test"}) }.to_not raise_error
|
38
|
+
expect(updated_project).to eq("OK")
|
39
|
+
fetched_project = @private_project.fetch_with_details
|
40
|
+
expect(fetched_project['description']).to eq('test')
|
41
|
+
end
|
42
|
+
it "should raise an error if updated field is wrong" do
|
43
|
+
expect { @private_project.update({:buttchick => "lol"}) }.to raise_error(Transifex::TransifexError)
|
44
|
+
end
|
45
|
+
it "should raise an error if no paramaters to update are provided" do
|
46
|
+
expect { @private_project.update }.to raise_error(Transifex::Error)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
describe "delete" do
|
50
|
+
it "should not raise an error" do
|
51
|
+
expect { @private_project.delete }.to_not raise_error
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
context "public project" do
|
56
|
+
describe "fetch" do
|
57
|
+
it "should retrieve informations about the project without details" do
|
58
|
+
fetched_project = nil
|
59
|
+
expect { fetched_project = @public_project.fetch }.to_not raise_error
|
60
|
+
expect(fetched_project).to be_a_kind_of(Hash)
|
61
|
+
expect(fetched_project.keys).to contain_exactly("slug", "name", "description","source_language_code")
|
62
|
+
end
|
63
|
+
it "should retrieve informations about the project with details" do
|
64
|
+
fetched_project = nil
|
65
|
+
expect { fetched_project = @public_project.fetch_with_details }.to_not raise_error
|
66
|
+
expect(fetched_project).to be_a_kind_of(Hash)
|
67
|
+
expect(fetched_project.keys).to contain_exactly("archived", "auto_join", "fill_up_resources", "homepage", "last_updated", "long_description", "maintainers", "organization", "private", "resources", "tags", "team", "teams", "trans_instructions", "slug", "name", "description","source_language_code")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
describe "update" do
|
71
|
+
it "should not raise an error and update the project" do
|
72
|
+
updated_project = nil
|
73
|
+
expect { updated_project = @public_project.update({:description => "test"}) }.to_not raise_error
|
74
|
+
expect(updated_project).to eq("OK")
|
75
|
+
end
|
76
|
+
it "should raise an error if updated field is wrong" do
|
77
|
+
updated_project = nil
|
78
|
+
expect { updated_project = @public_project.update({:buttchick => "lol"}) }.to raise_error(Transifex::TransifexError)
|
79
|
+
end
|
80
|
+
it "should raise an error if no paramaters to update are provided" do
|
81
|
+
expect { @public_project.update }.to raise_error(Transifex::Error)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
describe "delete" do
|
85
|
+
it "should not raise an error" do
|
86
|
+
expect { @public_project.delete }.to_not raise_error
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require_relative "../../spec_helper"
|
2
|
+
|
3
|
+
describe Transifex::Projects do
|
4
|
+
before(:all) do
|
5
|
+
@incorrect_params = {:slug => "test"}
|
6
|
+
@correct_params_private = {:slug => "projet_de_test_private", :name => "Projet de test Public", :description => "description", :source_language_code => "en", :private => true}
|
7
|
+
@correct_params_public = {:slug => "projet_de_test_public", :name => "Projet de test Private", :description => "description", :source_language_code => "en", :repository_url => "http://en.google.com"}
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "create" do
|
11
|
+
it "should raise an error if required parameters are missing" do
|
12
|
+
expect { Transifex::Projects.create(@incorrect_params) }.to raise_error(Transifex::MissingParametersError)
|
13
|
+
end
|
14
|
+
context "private project" do
|
15
|
+
it "should not raise an error if required parameters are provided and create the private project" do
|
16
|
+
created_project = nil
|
17
|
+
expect { created_project = Transifex::Projects.create(@correct_params_private) }.to_not raise_error
|
18
|
+
expect(created_project).to be_a_kind_of(Transifex::Project)
|
19
|
+
expect(created_project.project_slug).to eq(@correct_params_private[:slug])
|
20
|
+
created_project.delete
|
21
|
+
end
|
22
|
+
end
|
23
|
+
context "public project" do
|
24
|
+
it "should not raise an error if required parameters are provided and create the project" do
|
25
|
+
created_project = nil
|
26
|
+
expect { created_project = Transifex::Projects.create(@correct_params_public) }.to_not raise_error
|
27
|
+
expect(created_project).to be_a_kind_of(Transifex::Project)
|
28
|
+
expect(created_project.project_slug).to eq(@correct_params_public[:slug])
|
29
|
+
created_project.delete
|
30
|
+
end
|
31
|
+
it "should raise an error if repository_url is not matching the correct format" do
|
32
|
+
incorrect_params_public = @correct_params_public
|
33
|
+
incorrect_params_public[:repository_url] = "www.google.com"
|
34
|
+
expect { Transifex::Projects.create(@correct_params_public) }.to raise_error(Transifex::ParametersFormatError)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
describe "Fetch" do
|
39
|
+
it "should not raise an error and return an array of hash" do
|
40
|
+
fetched_projects = nil
|
41
|
+
expect{ fetched_projects = Transifex::Projects.fetch}.to_not raise_error
|
42
|
+
expect(fetched_projects).to be_a_kind_of(Array)
|
43
|
+
expect(fetched_projects).not_to match_array([])
|
44
|
+
expect(fetched_projects.first).to be_a_kind_of(Hash)
|
45
|
+
expect(fetched_projects.first.keys).to contain_exactly("slug", "name", "description","source_language_code")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative "../../spec_helper"
|
2
|
+
|
3
|
+
describe Transifex::ResourceComponents::Content do
|
4
|
+
before(:all) do
|
5
|
+
@project = Transifex::Project.new("projet-de-test-1")
|
6
|
+
@resource = @project.resource("test")
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "Instanciation" do
|
10
|
+
it "should raise an error when no parameters given" do
|
11
|
+
expect{ Transifex::ResourceComponents::Content.new }.to raise_error(ArgumentError)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "Fetch" do
|
16
|
+
it "should retrieve the resource content as a hash" do
|
17
|
+
resource_content = nil
|
18
|
+
expect{ resource_content = @resource.content.fetch }.to_not raise_error
|
19
|
+
expect(resource_content).to be_a_kind_of(Hash)
|
20
|
+
expect(resource_content.keys).to contain_exactly("content", "mimetype")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should retrieve the resource content as a file" do
|
24
|
+
resource_content = nil
|
25
|
+
path_to_file = File.dirname(__FILE__) + "/../yaml/resource_content_test.yml"
|
26
|
+
expect{ resource_content = @resource.content.fetch_with_file(path_to_file) }.to_not raise_error
|
27
|
+
file_exist = File.file?(path_to_file)
|
28
|
+
expect(file_exist).to eq(true)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "Update" do
|
33
|
+
it "should not raise an error and update the resource content" do
|
34
|
+
expect{ @resource.content.update({:i18n_type => "YAML", :content => get_yaml_source_trad_file_path('en')}) }.to_not raise_error
|
35
|
+
end
|
36
|
+
it "should raise an error if updated resource content is of a different type than the previous" do
|
37
|
+
expect{ @resource.content.update({:i18n_type => "TXT", :content => get_yaml_source_trad_file_path('en')}) }.to raise_error(Transifex::Error)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative "../../spec_helper"
|
2
|
+
|
3
|
+
describe Transifex::ResourceComponents::Source do
|
4
|
+
before(:all) do
|
5
|
+
@project = Transifex::Project.new("projet-de-test-1")
|
6
|
+
@resource = @project.resource("test")
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "Instanciation" do
|
10
|
+
it "should raise an error when no parameters given" do
|
11
|
+
expect{ Transifex::ResourceComponents::Source.new }.to raise_error(Transifex::MissingParametersError)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "Fetch" do
|
16
|
+
it "should retrieve the resource source string details as a hash" do
|
17
|
+
source_string_details = nil
|
18
|
+
expect{ source_string_details = @resource.source("routes.mercury_editor").fetch }.to_not raise_error
|
19
|
+
expect(source_string_details).to be_a_kind_of(Hash)
|
20
|
+
expect(source_string_details.keys).to contain_exactly("comment", "character_limit", "tags")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "Update" do
|
25
|
+
it "should not raise an error and update the source string details" do
|
26
|
+
params = {:comment => "test", :character_limit => 140, :tags => ["tag1", "tag2"]}
|
27
|
+
expect{ @resource.source("routes.mercury_editor").update(params) }.to_not raise_error
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe Transifex::Resource do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@correct_params_public = {:slug => "resource_test_project", :name => "Projet de test resource", :description => "description", :source_language_code => "en", :repository_url => "http://en.google.com"}
|
7
|
+
@project = Transifex::Projects.create(@correct_params_public)
|
8
|
+
@project.resources.create({:slug => "resource_test", :name => "resource_test", :i18n_type => "TXT", :content => "test"})
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should raise an error if project slug or Resource slug are not provided" do
|
12
|
+
expect{ Transifex::Resource.new(nil, "test") }.to raise_error(Transifex::MissingParametersError)
|
13
|
+
expect{ Transifex::Resource.new("test", nil) }.to raise_error(Transifex::MissingParametersError)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "Fetch" do
|
17
|
+
it "should raise an error if resource doesn't exist" do
|
18
|
+
expect{ @project.resource("wrong_slug").fetch }.to raise_error(Transifex::Error)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should not raise an error and retrieve the correct infos without details" do
|
22
|
+
fetched_resource = nil
|
23
|
+
expect{ fetched_resource = @project.resource("resource_test").fetch }.to_not raise_error
|
24
|
+
expect(fetched_resource).to be_a_kind_of(Hash)
|
25
|
+
expect(fetched_resource.keys).to contain_exactly("source_language_code", "name", "i18n_type", "priority", "slug", "categories")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should not raise an error and retrieve the correct infos with details" do
|
29
|
+
fetched_resource = nil
|
30
|
+
expect{ fetched_resource = @project.resource("resource_test").fetch_with_details }.to_not raise_error
|
31
|
+
expect(fetched_resource).to be_a_kind_of(Hash)
|
32
|
+
expect(fetched_resource.keys).to contain_exactly("source_language_code", "name", "created", "wordcount", "i18n_type", "project_slug", "accept_translations", "last_update", "priority", "available_languages", "total_entities", "slug", "categories")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "Update" do
|
37
|
+
it "should raise an error if resource doesn't exist" do
|
38
|
+
expect{ @project.resource("wrong_slug").update }.to raise_error(Transifex::Error)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should update multiple attributes" do
|
42
|
+
expect{ fetched_resource = @project.resource("resource_test").update({name: "new_name", categories: ["test1", "test2"]}) }.to_not raise_error
|
43
|
+
fetched_resource = @project.resource("resource_test").fetch
|
44
|
+
expect(fetched_resource['name']).to eq("new_name")
|
45
|
+
expect(fetched_resource['categories']).to be_a_kind_of(Array)
|
46
|
+
expect(fetched_resource['categories'].join(',')).to eq("test1,test2")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "Delete" do
|
51
|
+
it "should raise an error if resource doesn't exist" do
|
52
|
+
expect{ @project.resource("wrong_slug").delete }.to raise_error(Transifex::Error)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should delete a resource" do
|
56
|
+
@project.resources.create({:slug => "resource_delete_test", :name => "resource_delete_test", :i18n_type => "TXT", :content => "test"})
|
57
|
+
expect{ @project.resource("resource_delete_test").fetch }.to_not raise_error
|
58
|
+
expect{ @project.resource("resource_delete_test").delete }.to_not raise_error
|
59
|
+
expect{ @project.resource("resource_delete_test").fetch }.to raise_error
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
after(:all) do
|
64
|
+
@project.delete
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_relative "../../spec_helper"
|
2
|
+
|
3
|
+
describe Transifex::Resources do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@correct_project = Transifex::Project.new("projet-de-test-1")
|
7
|
+
@wrong_project = Transifex::Project.new("lll")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should raise an error if instanciated without a project_slug" do
|
11
|
+
expect{ Transifex::Resources.new() }.to raise_error(Transifex::MissingParametersError)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "Fetch" do
|
15
|
+
it "should not raise any error and return a hash" do
|
16
|
+
resources_instance = @correct_project.resources
|
17
|
+
fetched_resources = nil
|
18
|
+
expect{ fetched_resources = resources_instance.fetch }.to_not raise_error
|
19
|
+
expect(fetched_resources).to be_a_kind_of(Array)
|
20
|
+
expect(fetched_resources.first).to be_a_kind_of(Hash)
|
21
|
+
expect(fetched_resources.first.keys).to contain_exactly("source_language_code", "name", "i18n_type", "priority", "slug", "categories")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should raise an error if project doesn't exist" do
|
25
|
+
resources_instance = @wrong_project.resources
|
26
|
+
fetched_resources = nil
|
27
|
+
expect{ fetched_resources = resources_instance.fetch }.to raise_error(Transifex::TransifexError)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "Create" do
|
32
|
+
it "should raise an error if required parameters are missing" do
|
33
|
+
expect{ @correct_project.resources.create }.to raise_error(Transifex::MissingParametersError)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should create a new resource for the project without using a file" do
|
37
|
+
expect{ @correct_project.resources.create({:slug => "p", :name => "without_file", :i18n_type => "TXT", :content => "test"}) }.to_not raise_error
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should create a new resource for the project using a file" do
|
41
|
+
options = {:trad_from_file => true}
|
42
|
+
expect{ @correct_project.resources.create({:slug => "q", :name => "with_file", :i18n_type => "YAML", :content => get_yaml_source_trad_file_path('en')}, options) }.to_not raise_error
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
after(:all) do
|
47
|
+
@correct_project.resource("q").delete
|
48
|
+
@correct_project.resource("p").delete
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe Transifex::ProjectComponents::LanguageComponents::Reviewers do
|
4
|
+
before(:all) do
|
5
|
+
@project = Transifex::Project.new("projet-de-test-1")
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "Instanciation" do
|
9
|
+
it "should raise an error when no parameters given" do
|
10
|
+
expect{ Transifex::ProjectComponents::LanguageComponents::Reviewers.new }.to raise_error(Transifex::MissingParametersError)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "Fetch" do
|
15
|
+
it "should not raise an error and retrieve the language's informations" do
|
16
|
+
language_coordinators_infos = nil
|
17
|
+
expect{ language_coordinators_infos = @project.language('en').reviewers.fetch }.to_not raise_error
|
18
|
+
expect(language_coordinators_infos).to be_a_kind_of(Hash)
|
19
|
+
expect(language_coordinators_infos.keys).to contain_exactly("reviewers")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "Update" do
|
24
|
+
it "should not raise an error and update the coordinators list" do
|
25
|
+
expect{ @project.language('en').reviewers.update(['fredericgrais'])}.to_not raise_error
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should raise an error if the coordinator doesn't exist" do
|
29
|
+
expect{ @project.language('en').reviewers.update(['grgrgef'])}.to raise_error(Transifex::TransifexError)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|