babelish_rnc 1.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.babelish.sample +35 -0
- data/.gitignore +34 -0
- data/.hound.yml +4 -0
- data/.travis.yml +15 -0
- data/CONTRIBUTING.md +12 -0
- data/Dockerfile +6 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +20 -0
- data/README.md +73 -0
- data/Rakefile +17 -0
- data/babelish.gemspec +41 -0
- data/babelish_rnc.gemspec +42 -0
- data/bin/babelish_rnc +6 -0
- data/lib/babelish_rnc.rb +31 -0
- data/lib/babelish_rnc/android2csv.rb +28 -0
- data/lib/babelish_rnc/base2csv.rb +103 -0
- data/lib/babelish_rnc/commandline.rb +188 -0
- data/lib/babelish_rnc/csv2android.rb +53 -0
- data/lib/babelish_rnc/csv2base.rb +189 -0
- data/lib/babelish_rnc/csv2json.rb +21 -0
- data/lib/babelish_rnc/csv2php.rb +25 -0
- data/lib/babelish_rnc/csv2strings.rb +34 -0
- data/lib/babelish_rnc/google_doc.rb +55 -0
- data/lib/babelish_rnc/json2csv.rb +20 -0
- data/lib/babelish_rnc/language.rb +30 -0
- data/lib/babelish_rnc/php2csv.rb +30 -0
- data/lib/babelish_rnc/strings2csv.rb +61 -0
- data/lib/babelish_rnc/version.rb +3 -0
- data/lib/babelish_rnc/xcode_macros.rb +49 -0
- data/test/babelish_rnc/commands/test_command_android2csv.rb +60 -0
- data/test/babelish_rnc/commands/test_command_csv2android.rb +35 -0
- data/test/babelish_rnc/commands/test_command_csv2strings.rb +139 -0
- data/test/babelish_rnc/commands/test_command_strings2csv.rb +110 -0
- data/test/babelish_rnc/test_android2csv.rb +53 -0
- data/test/babelish_rnc/test_base2csv.rb +43 -0
- data/test/babelish_rnc/test_bins.rb +32 -0
- data/test/babelish_rnc/test_commandline.rb +127 -0
- data/test/babelish_rnc/test_csv2android.rb +72 -0
- data/test/babelish_rnc/test_csv2base.rb +44 -0
- data/test/babelish_rnc/test_csv2json.rb +27 -0
- data/test/babelish_rnc/test_csv2php.rb +27 -0
- data/test/babelish_rnc/test_csv2strings.rb +154 -0
- data/test/babelish_rnc/test_json2csv.rb +34 -0
- data/test/babelish_rnc/test_php2csv.rb +73 -0
- data/test/babelish_rnc/test_strings2csv.rb +147 -0
- data/test/babelish_rnc/test_xcode_macros.rb +112 -0
- data/test/data/android-en.xml +9 -0
- data/test/data/android-fr.xml +9 -0
- data/test/data/android.xml +9 -0
- data/test/data/android_special_chars.csv +8 -0
- data/test/data/android_special_chars.xml +12 -0
- data/test/data/android_special_chars_test_result.xml +10 -0
- data/test/data/genstrings.strings +0 -0
- data/test/data/json.json +6 -0
- data/test/data/php_lang.php +8 -0
- data/test/data/test_comments.strings +2 -0
- data/test/data/test_data.csv +3 -0
- data/test/data/test_data.strings +2 -0
- data/test/data/test_data_fr_with_comments.strings +6 -0
- data/test/data/test_data_fr_with_comments.xml +9 -0
- data/test/data/test_data_multiple_langs.csv +3 -0
- data/test/data/test_data_with_comments.csv +3 -0
- data/test/data/test_data_with_percent.csv +3 -0
- data/test/data/test_data_with_percent_space.csv +4 -0
- data/test/data/test_data_with_semicolon.csv +3 -0
- data/test/data/test_data_with_spaces.csv +3 -0
- data/test/data/test_en.strings +2 -0
- data/test/data/test_fr.strings +2 -0
- data/test/data/test_space.strings +10 -0
- data/test/data/test_utf16.strings +0 -0
- data/test/data/test_with_nil.csv +3 -0
- data/test/data/test_with_nil.strings +4 -0
- data/test/data/xcode_empty.strings +7 -0
- data/test/test_helper.rb +17 -0
- metadata +311 -0
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
class TestStrings2CSVCommand < Test::Unit::TestCase
|
3
|
+
|
4
|
+
def test_strings2csv
|
5
|
+
options = {:filenames => ["test/data/test_data.strings"]}
|
6
|
+
Commandline.new([], options).strings2csv
|
7
|
+
|
8
|
+
assert File.exist?("translations.csv")
|
9
|
+
|
10
|
+
# clean up
|
11
|
+
system("rm -f translations.csv")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_strings2csv_with_dryrun_option
|
15
|
+
options = {:filenames => ["test/data/test_data.strings"], :dryrun => true}
|
16
|
+
Commandline.new([], options).strings2csv
|
17
|
+
|
18
|
+
assert !File.exist?("translations.csv")
|
19
|
+
|
20
|
+
# clean up
|
21
|
+
system("rm -f translations.csv")
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_strings2csv_with_output_file
|
25
|
+
options = {:filenames => ["test/data/test_data.strings"], :csv_filename => "myfile.csv"}
|
26
|
+
# -i, -o
|
27
|
+
Commandline.new([], options).strings2csv
|
28
|
+
|
29
|
+
assert File.exist?("myfile.csv")
|
30
|
+
|
31
|
+
# clean up
|
32
|
+
system("rm -f myfile.csv")
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_strings2csv_with_headers
|
36
|
+
options = {:filenames => ["test/data/test_data.strings"], :headers => ["constants", "english"]}
|
37
|
+
# -i, -h
|
38
|
+
Commandline.new([], options).strings2csv
|
39
|
+
|
40
|
+
#TODO assertion or move test on at lib level
|
41
|
+
|
42
|
+
# clean up
|
43
|
+
system("rm -f translations.csv")
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_strings2csv_with_two_files
|
47
|
+
options = {
|
48
|
+
:filenames => ["test/data/test_en.strings", "test/data/test_fr.strings"],
|
49
|
+
:headers => %w{Constants English French},
|
50
|
+
:csv_filename => "enfr.csv"
|
51
|
+
}
|
52
|
+
# --filenames, --headers, -o
|
53
|
+
Commandline.new([], options).strings2csv
|
54
|
+
|
55
|
+
#TODO assertion
|
56
|
+
|
57
|
+
# clean up
|
58
|
+
system("rm -f enfr.csv")
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_strings2csv_with_empty_lines
|
62
|
+
options = {
|
63
|
+
:filenames => ["test/data/test_with_nil.strings"],
|
64
|
+
:csv_filename => "test_with_nil.csv"
|
65
|
+
}
|
66
|
+
# -i, -o
|
67
|
+
|
68
|
+
|
69
|
+
assert_nothing_raised do
|
70
|
+
Commandline.new([], options).strings2csv
|
71
|
+
end
|
72
|
+
assert system("diff test_with_nil.csv test/data/test_with_nil.csv"), "no difference on output"
|
73
|
+
|
74
|
+
# clean up
|
75
|
+
system("rm -f test_with_nil.csv")
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_strings2csv_utf16
|
79
|
+
options = {
|
80
|
+
:filenames => ["test/data/test_utf16.strings"],
|
81
|
+
:csv_filename => "test_utf16.csv"
|
82
|
+
}
|
83
|
+
# -i, -o
|
84
|
+
|
85
|
+
|
86
|
+
assert_nothing_raised do
|
87
|
+
Commandline.new([], options).strings2csv
|
88
|
+
end
|
89
|
+
|
90
|
+
# clean up
|
91
|
+
system("rm -f test_utf16.csv")
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_strings2csv_with_comments_outputs_right_headers
|
96
|
+
expected_content = <<-EOF
|
97
|
+
Variables,test/data/test_comments.strings,Comments
|
98
|
+
MY_CONSTANT,This 'is' ok,this is a comment
|
99
|
+
EOF
|
100
|
+
|
101
|
+
options = { :filenames => ["test/data/test_comments.strings"] }
|
102
|
+
Commandline.new([], options).strings2csv
|
103
|
+
|
104
|
+
csv_content = `cat translations.csv`
|
105
|
+
|
106
|
+
assert_equal expected_content, csv_content, "Content of generated file differs from expected one"
|
107
|
+
# clean up
|
108
|
+
system("rm -f translations.csv")
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
class TestAndroid2CSV < Test::Unit::TestCase
|
3
|
+
|
4
|
+
def test_load_strings_with_wrong_file
|
5
|
+
assert_raise(Errno::ENOENT) do
|
6
|
+
output = BabelishRnc::Android2CSV.new.load_strings "file that does not exist.strings"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_load_strings
|
11
|
+
expected_output = [{"app_name" => "android2csv", "action_greetings" => "Hello", "ANOTHER_STRING" => "testEN", "empty" => ""}, {}]
|
12
|
+
output = BabelishRnc::Android2CSV.new.load_strings "test/data/android.xml"
|
13
|
+
assert_equal expected_output, output
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_initialize
|
17
|
+
csv_filename = "file.csv"
|
18
|
+
filenames = %w{french.strings english.strings}
|
19
|
+
headers = %w{constants french english}
|
20
|
+
converter = BabelishRnc::Android2CSV.new(
|
21
|
+
:csv_filename => csv_filename,
|
22
|
+
:headers => headers,
|
23
|
+
:filenames => filenames)
|
24
|
+
|
25
|
+
assert_equal csv_filename, converter.csv_filename
|
26
|
+
assert_equal headers, converter.headers
|
27
|
+
assert_equal filenames, converter.filenames
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_initialize_with_default_values
|
31
|
+
converter = BabelishRnc::Android2CSV.new
|
32
|
+
assert_not_nil converter.csv_filename
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_special_chars
|
36
|
+
csv_filename = "./android_special_chars_output.csv"
|
37
|
+
filenames = "test/data/android_special_chars.xml"
|
38
|
+
headers = %w{variables german}
|
39
|
+
|
40
|
+
converter = BabelishRnc::Android2CSV.new(
|
41
|
+
:csv_filename => csv_filename,
|
42
|
+
:headers => headers,
|
43
|
+
:filenames => [filenames])
|
44
|
+
|
45
|
+
converter.convert
|
46
|
+
|
47
|
+
assert File.exist?(converter.csv_filename)
|
48
|
+
assert_equal File.read("test/data/android_special_chars.csv"), File.read(csv_filename)
|
49
|
+
|
50
|
+
# clean up
|
51
|
+
system("rm -rf ./" + csv_filename)
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
class TestBase2Csv < Test::Unit::TestCase
|
3
|
+
|
4
|
+
def test_load_strings
|
5
|
+
expected_output = [{}, {}]
|
6
|
+
output = BabelishRnc::Base2Csv.new.send :load_strings, nil
|
7
|
+
assert_equal expected_output, output
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_create_csv_file
|
11
|
+
keys = ["ERROR_HANDLER_WARNING_DISMISS", "ANOTHER_STRING"]
|
12
|
+
filename = "test_data"
|
13
|
+
strings = {filename => {"ERROR_HANDLER_WARNING_DISMISS" => "OK", "ANOTHER_STRING" => "hello"}}
|
14
|
+
|
15
|
+
converter = BabelishRnc::Base2Csv.new(:headers => %w{variables english}, :filenames => [filename])
|
16
|
+
|
17
|
+
converter.send :create_csv_file, keys, strings
|
18
|
+
assert File.exist?(converter.csv_filename)
|
19
|
+
|
20
|
+
# clean up
|
21
|
+
system("rm -rf ./" + converter.csv_filename)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_initialize
|
25
|
+
csv_filename = "file.csv"
|
26
|
+
filenames = %w{"french.strings english.strings"}
|
27
|
+
headers = %w{"constants french english"}
|
28
|
+
converter = BabelishRnc::Base2Csv.new({
|
29
|
+
:csv_filename => csv_filename,
|
30
|
+
:headers => headers,
|
31
|
+
:filenames => filenames
|
32
|
+
})
|
33
|
+
|
34
|
+
assert_equal csv_filename, converter.csv_filename
|
35
|
+
assert_equal headers, converter.headers
|
36
|
+
assert_equal filenames, converter.filenames
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_initialize_with_default_values
|
40
|
+
converter = BabelishRnc::Base2Csv.new
|
41
|
+
assert_not_nil converter.csv_filename
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
class TestBins < Test::Unit::TestCase
|
3
|
+
|
4
|
+
def test_csv2strings_with_google_doc
|
5
|
+
omit if ENV['TRAVIS']
|
6
|
+
assert_nothing_raised do
|
7
|
+
system("./bin/babelish_rnc csv2strings --fetch --filename my_strings --langs English:en")
|
8
|
+
end
|
9
|
+
assert_equal 0, $?.exitstatus
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_csv2strings_with_google_doc_missing_langs
|
13
|
+
omit if ENV['TRAVIS']
|
14
|
+
assert_nothing_raised do
|
15
|
+
system("./bin/babelish_rnc csv2strings --fetch --filename my_strings")
|
16
|
+
end
|
17
|
+
assert_equal 1, $?.exitstatus
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_csv2strings_with_config_file
|
21
|
+
system("cp .babelish.sample .babelish")
|
22
|
+
|
23
|
+
assert_nothing_raised NameError do
|
24
|
+
system("./bin/babelish_rnc csv2strings")
|
25
|
+
end
|
26
|
+
assert_equal 0, $?.exitstatus
|
27
|
+
end
|
28
|
+
|
29
|
+
def teardown
|
30
|
+
system("rm -f .babelish")
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
class TestCommandLine < Test::Unit::TestCase
|
3
|
+
|
4
|
+
def test_init
|
5
|
+
assert_nothing_raised do
|
6
|
+
Commandline.new.init
|
7
|
+
end
|
8
|
+
# clean up
|
9
|
+
system("rm -f .babelish")
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_csv2base_with_config_file_all_required_options
|
13
|
+
options = {
|
14
|
+
:filename => "test/data/test_data_multiple_langs.csv",
|
15
|
+
:langs => {"English" => "en", "French" => "fr"}
|
16
|
+
}
|
17
|
+
config_file = File.new(".babelish", "w")
|
18
|
+
config_file.write options.to_yaml
|
19
|
+
config_file.close
|
20
|
+
|
21
|
+
assert_nothing_raised do
|
22
|
+
Commandline.new.csv2strings
|
23
|
+
end
|
24
|
+
|
25
|
+
# clean up
|
26
|
+
system("rm -rf ./en.lproj/")
|
27
|
+
system("rm -rf ./fr.lproj/")
|
28
|
+
system("rm -f .babelish")
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
def test_csv2base_without_filename_fails
|
33
|
+
options = {
|
34
|
+
:langs => {"English" => "en", "French" => "fr"}
|
35
|
+
}
|
36
|
+
config_file = File.new(".babelish", "w")
|
37
|
+
config_file.write options.to_yaml
|
38
|
+
config_file.close
|
39
|
+
|
40
|
+
assert_raises do
|
41
|
+
Commandline.new.csv2strings
|
42
|
+
end
|
43
|
+
|
44
|
+
# clean up
|
45
|
+
system("rm -rf ./en.lproj/")
|
46
|
+
system("rm -rf ./fr.lproj/")
|
47
|
+
system("rm -f .babelish")
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_base2csv_with_config_file_all_required_options
|
51
|
+
options = {
|
52
|
+
:filenames => ["test/data/test_en.strings", "test/data/test_fr.strings"],
|
53
|
+
}
|
54
|
+
config_file = File.new(".babelish", "w")
|
55
|
+
config_file.write options.to_yaml
|
56
|
+
config_file.close
|
57
|
+
|
58
|
+
assert_nothing_raised do
|
59
|
+
Commandline.new.strings2csv
|
60
|
+
end
|
61
|
+
|
62
|
+
# clean up
|
63
|
+
system("rm -f translations.csv")
|
64
|
+
system("rm -f .babelish")
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_base2csv_with_config_without_filenames_fails
|
68
|
+
options = {}
|
69
|
+
config_file = File.new(".babelish", "w")
|
70
|
+
config_file.write options.to_yaml
|
71
|
+
config_file.close
|
72
|
+
|
73
|
+
assert_raises do
|
74
|
+
Commandline.new.strings2csv
|
75
|
+
end
|
76
|
+
|
77
|
+
# clean up
|
78
|
+
system("rm -f .babelish")
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_base2csv_with_config_with_non_existent_filenames_fails
|
82
|
+
options = {:filenames => ['foo']}
|
83
|
+
config_file = File.new(".babelish", "w")
|
84
|
+
config_file.write options.to_yaml
|
85
|
+
config_file.close
|
86
|
+
|
87
|
+
_, stderr = capture_output do
|
88
|
+
Commandline.new.strings2csv
|
89
|
+
end
|
90
|
+
assert_match(/No such file or directory/, stderr)
|
91
|
+
assert_match(/foo/, stderr)
|
92
|
+
|
93
|
+
# clean up
|
94
|
+
system("rm -f .babelish")
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_csv_download_without_gd_filename_fails
|
98
|
+
options = {}
|
99
|
+
config_file = File.new(".babelish", "w")
|
100
|
+
config_file.write options.to_yaml
|
101
|
+
config_file.close
|
102
|
+
|
103
|
+
assert_raises do
|
104
|
+
Commandline.new.csv_download
|
105
|
+
end
|
106
|
+
|
107
|
+
# clean up
|
108
|
+
system("rm -f .babelish")
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
def test_csv_download_with_required_params
|
113
|
+
omit if ENV['TRAVIS']
|
114
|
+
options = {:gd_filename => "my_strings"}
|
115
|
+
config_file = File.new(".babelish", "w")
|
116
|
+
config_file.write options.to_yaml
|
117
|
+
config_file.close
|
118
|
+
|
119
|
+
assert_nothing_raised do
|
120
|
+
Commandline.new.csv_download
|
121
|
+
end
|
122
|
+
|
123
|
+
# clean up
|
124
|
+
system("rm -f .babelish")
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
class TestCSV2Android < Test::Unit::TestCase
|
3
|
+
|
4
|
+
def test_converting_csv_to_xml
|
5
|
+
csv_file = "test/data/test_data.csv"
|
6
|
+
converter = BabelishRnc::CSV2Android.new(csv_file, "English" => "en")
|
7
|
+
converter.convert
|
8
|
+
assert File.exist?("values-en/strings.xml"), "the ouptut file does not exist"
|
9
|
+
|
10
|
+
# clean up
|
11
|
+
system("rm -rf ./values-en")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_converting_csv_with_special_chars
|
15
|
+
csv_file = "test/data/android_special_chars.csv"
|
16
|
+
converter = BabelishRnc::CSV2Android.new(csv_file, "german" => "de")
|
17
|
+
converter.convert
|
18
|
+
assert File.exist?("values-de/strings.xml"), "the ouptut file does not exist"
|
19
|
+
assert_equal File.read("test/data/android_special_chars_test_result.xml"), File.read("values-de/strings.xml")
|
20
|
+
|
21
|
+
# clean up
|
22
|
+
system("rm -rf ./values-de")
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_converting_csv_to_dotstrings_one_output_option
|
26
|
+
csv_file = "test/data/test_data.csv"
|
27
|
+
single_file = "myApp.xml"
|
28
|
+
converter = BabelishRnc::CSV2Android.new(
|
29
|
+
csv_file,
|
30
|
+
{ "English" => "en" },
|
31
|
+
:output_basename => "myApp",
|
32
|
+
:ignore_lang_path => true
|
33
|
+
)
|
34
|
+
converter.convert
|
35
|
+
assert File.exist?(single_file), "the ouptut file does not exist"
|
36
|
+
|
37
|
+
# clean up
|
38
|
+
system("rm -rf ./" + single_file)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_converting_with_comments
|
42
|
+
csv_file = "test/data/test_data_with_comments.csv"
|
43
|
+
french_file = "values-fr/strings.xml"
|
44
|
+
expected_output = File.read("test/data/test_data_fr_with_comments.xml")
|
45
|
+
converter = BabelishRnc::CSV2Android.new(
|
46
|
+
csv_file,
|
47
|
+
{ "French" => "fr" },
|
48
|
+
:default_lang => "English",
|
49
|
+
:comments_column => 5
|
50
|
+
)
|
51
|
+
converter.convert
|
52
|
+
assert File.exist?(french_file), "the ouptut file does not exist"
|
53
|
+
result = File.read(french_file)
|
54
|
+
assert_equal expected_output, result
|
55
|
+
|
56
|
+
# clean up
|
57
|
+
system("rm -rf values-fr")
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_converting_with_basename
|
61
|
+
csv_file = "test/data/test_data.csv"
|
62
|
+
converter = BabelishRnc::CSV2Android.new(csv_file,
|
63
|
+
{ "English" => "en" },
|
64
|
+
{ output_basename: "super_strings" })
|
65
|
+
converter.convert
|
66
|
+
exist = File.exist?("values-en/super_strings.xml")
|
67
|
+
assert exist, "the ouptut file does not exist"
|
68
|
+
|
69
|
+
# clean up
|
70
|
+
system("rm -rf ./values-en")
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
class TestCsv2Base < Test::Unit::TestCase
|
3
|
+
|
4
|
+
def test_initialize
|
5
|
+
csv_filename = "file.csv"
|
6
|
+
excluded_states = ["German"]
|
7
|
+
state_column = "Local"
|
8
|
+
keys_column = 23
|
9
|
+
converter = BabelishRnc::Csv2Base.new(csv_filename, {"English" => ["en"]}, {
|
10
|
+
:excluded_states => excluded_states,
|
11
|
+
:state_column => state_column,
|
12
|
+
:keys_column => keys_column })
|
13
|
+
|
14
|
+
assert_equal csv_filename, converter.csv_filename
|
15
|
+
assert_equal excluded_states, converter.excluded_states
|
16
|
+
assert_equal state_column, converter.state_column
|
17
|
+
assert_equal keys_column, converter.keys_column
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_initialize_with_default_values
|
21
|
+
converter = BabelishRnc::Csv2Base.new("file.csv", "English" => ["en"])
|
22
|
+
assert_not_nil converter.csv_filename
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_initialize_with_custom_separator
|
26
|
+
converter = BabelishRnc::Csv2Base.new("file.csv", { "English" => ["en"] }, { :csv_separator => ";" })
|
27
|
+
assert_not_nil converter.csv_filename
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_create_file_from_path
|
31
|
+
test_file = "test_file.txt"
|
32
|
+
BabelishRnc::Csv2Base.new("file.csv", "English" => ["en"]).create_file_from_path test_file
|
33
|
+
assert File.exist?(test_file)
|
34
|
+
|
35
|
+
# clean up
|
36
|
+
system("rm -rf ./" + test_file)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_get_row_format
|
40
|
+
expected_output = "\"test_key\" = \"test_value\""
|
41
|
+
output = BabelishRnc::Csv2Base.new("file.csv", "English" => ["en"]).get_row_format("test_key", "test_value")
|
42
|
+
assert_equal expected_output, output
|
43
|
+
end
|
44
|
+
end
|