Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for Google Drive API #81

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .hound.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ HashSyntax:
Enabled: false
LineLength:
Enabled: false
fail_on_violations: true
4 changes: 3 additions & 1 deletion babelish.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ Gem::Specification.new do |s|
s.add_development_dependency "test-unit"
s.add_development_dependency "simplecov"
s.add_development_dependency "yard"

s.add_development_dependency "vcr"
s.add_development_dependency "webmock"

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
Expand Down
18 changes: 11 additions & 7 deletions test/babelish/commands/test_command_csv2strings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ def test_csv2strings_with_output_dir
end

def test_csv2strings_with_fetch_google_doc
omit if ENV['TRAVIS']
options = {
:filename => "my_strings",
:langs => {"English" => "en", "French" => "fr"},
:fetch => true
}
assert_nothing_raised do
Commandline.new([], options).csv2strings

VCR.use_cassette("my_strings_fetch_google_doc") do
assert_nothing_raised do
Commandline.new([], options).csv2strings
end
end

# clean up
Expand All @@ -61,15 +63,16 @@ def test_csv2strings_with_config_file
end

def test_csv2strings_with_output_basenames_option
omit if ENV['TRAVIS']
options = {
:filename => "my_strings",
:langs => {"English" => "en", "French" => "fr"},
:fetch => true,
:output_basenames => %w(sheet1 sheet2),
}
VCR.use_cassette("my_strings_fetch_google_doc") do
Commandline.new([], options).csv2strings
end

Commandline.new([], options).csv2strings
# testing
assert File.exist?("./en.lproj/sheet1.strings"), "can't find output file for sheet1 English"
assert File.exist?("./fr.lproj/sheet1.strings"), "can't find output file for sheet1 French"
Expand All @@ -82,7 +85,6 @@ def test_csv2strings_with_output_basenames_option
end

def test_csv2strings_with_ignore_lang_path_option
omit if ENV['TRAVIS']
options = {
:filename => "my_strings",
:langs => {"English" => "en"},
Expand All @@ -91,7 +93,9 @@ def test_csv2strings_with_ignore_lang_path_option
:output_basenames => %w(sheet1 sheet2),
}

Commandline.new([], options).csv2strings
VCR.use_cassette("my_strings_fetch_google_doc") do
Commandline.new([], options).csv2strings
end
# testing
assert File.exist?("./sheet1.strings"), "can't find output file for sheet1 English with_ignore_lang_path_option"
assert File.exist?("./sheet2.strings"), "can't find output file for sheet2 English with_ignore_lang_path_option"
Expand Down
14 changes: 8 additions & 6 deletions test/babelish/test_bins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
class TestBins < Test::Unit::TestCase

def test_csv2strings_with_google_doc
omit if ENV['TRAVIS']
assert_nothing_raised do
system("./bin/babelish csv2strings --fetch --filename my_strings --langs English:en")
VCR.use_cassette("my_strings_fetch_google_doc") do
assert_nothing_raised do
system("./bin/babelish csv2strings --fetch --filename my_strings --langs English:en")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [93/80]

end
end
assert_equal 0, $?.exitstatus
end

def test_csv2strings_with_google_doc_missing_langs
omit if ENV['TRAVIS']
assert_nothing_raised do
system("./bin/babelish csv2strings --fetch --filename my_strings")
VCR.use_cassette("my_strings_fetch_google_doc") do
assert_nothing_raised do
system("./bin/babelish csv2strings --fetch --filename my_strings")
end
end
assert_equal 1, $?.exitstatus
end
Expand Down
7 changes: 4 additions & 3 deletions test/babelish/test_commandline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,15 @@ def test_csv_download_without_gd_filename_fails


def test_csv_download_with_required_params
omit if ENV['TRAVIS']
options = {:gd_filename => "my_strings"}
config_file = File.new(".babelish", "w")
config_file.write options.to_yaml
config_file.close

assert_nothing_raised do
Commandline.new.csv_download
VCR.use_cassette("my_strings_fetch_google_doc") do
assert_nothing_raised do
Commandline.new.csv_download
end
end

#clean up
Expand Down
Loading