Skip to content

Commit

Permalink
Merge d24157f into 6830aa9
Browse files Browse the repository at this point in the history
  • Loading branch information
netbe committed Nov 10, 2015
2 parents 6830aa9 + d24157f commit 33954c5
Show file tree
Hide file tree
Showing 11 changed files with 1,755 additions and 24 deletions.
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'
class TestGoogleDoc < Test::Unit::TestCase


# 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"}

# 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


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

end

end

0 comments on commit 33954c5

Please sign in to comment.