Skip to content

Add tests for Google Drive API #81

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ source "http://rubygems.org"
gemspec

group :test do
gem 'coveralls', :require => false, :platforms => [:ruby_19, :ruby_20]
gem 'coveralls', :require => false, :platforms => [:ruby_20]
end
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

mock_google_doc_strings_file 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),
}
mock_google_doc_strings_file 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
mock_google_doc_strings_file 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
15 changes: 9 additions & 6 deletions test/babelish/test_bins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
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")
mock_google_doc_strings_file do
assert_nothing_raised do
system("./bin/babelish csv2strings --fetch --filename my_strings \
--langs English:en")
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")
mock_google_doc_strings_file 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
mock_google_doc_strings_file do
assert_nothing_raised do
Commandline.new.csv_download
end
end

#clean up
Expand Down
43 changes: 43 additions & 0 deletions test/babelish/test_google_doc.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
require 'test_helper'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

class TestGoogleDoc < Test::Unit::TestCase

Copy link
Collaborator

Choose a reason for hiding this comment

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

Extra empty line detected at class body beginning.


Copy link
Collaborator

Choose a reason for hiding this comment

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

Extra blank line detected.

# def test_authenticate_without_token
# system "rm .babelish.token"
# gd = Babelish::GoogleDoc.new
# assert_nothing_raised do
# VCR.use_cassette("auth_google_doc") do
# gd.authenticate
# end
# end
# end

# {"refresh_token":"1/UHxZJZhky4MIePnAKlDWpnol-P_rVDTYxNt3h92_ilRIgOrJDtdun6zK6XiATCKT"}
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. [90/80]


# def test_authenticate_with_refresh_token
# gd = Babelish::GoogleDoc.new
# assert_nothing_raised do
# VCR.use_cassette("refresh_token") do
# gd.authenticate
# end
# end
# end


Copy link
Collaborator

Choose a reason for hiding this comment

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

Extra blank line detected.

def test_download_my_strings
gd = Babelish::GoogleDoc.new
# assert_nothing_raised do
# VCR.use_cassette("refresh_token") do
# gd.authenticate
# end
# end
system 'echo {\"refresh_token\":\"fake_token\"} > .babelish.token'
VCR.use_cassette("download_strings") do
VCR.use_cassette("refresh_token") do
gd.download "my_strings"
end
end

Copy link
Collaborator

Choose a reason for hiding this comment

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

Extra empty line detected at method body end.

end

Copy link
Collaborator

Choose a reason for hiding this comment

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

Extra empty line detected at class body end.

end
Loading