Skip to content

Commit

Permalink
Merge pull request #93 from tkbky/enhancement/better-file-not-exists-…
Browse files Browse the repository at this point in the history
…error-handling

Better file not exists error handling
  • Loading branch information
netbe committed Oct 11, 2016
2 parents 175295e + 6db7768 commit 3036a89
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/babelish/commandline.rb
Expand Up @@ -54,7 +54,11 @@ class Commandline < Thor
method_option :headers, :type => :array, :aliases => "-h", :desc => "override headers of columns, default is name of input files and 'Variables' for reference"
method_option :dryrun, :type => :boolean, :aliases => "-n", :desc => "prints out content of hash without writing file"
define_method("#{klass[:name].downcase}") do
base2csv(klass[:name])
begin
base2csv(klass[:name])
rescue Errno::ENOENT => e
warn e.message
end
end
end

Expand Down
16 changes: 16 additions & 0 deletions test/babelish/test_commandline.rb
Expand Up @@ -78,6 +78,22 @@ def test_base2csv_with_config_without_filenames_fails
system("rm -f .babelish")
end

def test_base2csv_with_config_with_non_existent_filenames_fails
options = {:filenames => ['foo']}
config_file = File.new(".babelish", "w")
config_file.write options.to_yaml
config_file.close

_, stderr = capture_output do
Commandline.new.strings2csv
end
assert_match(/No such file or directory/, stderr)
assert_match(/foo/, stderr)

# clean up
system("rm -f .babelish")
end

def test_csv_download_without_gd_filename_fails
options = {}
config_file = File.new(".babelish", "w")
Expand Down

0 comments on commit 3036a89

Please sign in to comment.