Permalink
Browse files

Better error message when target dir for locales does not exist

  • Loading branch information...
1 parent 2967dd3 commit cd368abb370667902e58e177e5b24263d88129dc @rmehner rmehner committed Jan 13, 2012
Showing with 15 additions and 0 deletions.
  1. +10 −0 features/localeapp_binary.feature
  2. +5 −0 lib/localeapp/updater.rb
@@ -99,6 +99,16 @@ Feature: localeapp executable
And help should not be displayed
And a file named "config/locales/en.yml" should exist
+ Scenario: Running pull without having a locales dir
+ In order to retreive my translations
+ Given I have a translations on localeapp.com for the project with api key "MYAPIKEY"
+ And an initializer file
+ When I run `localeapp pull`
+ Then the output should contain:
+ """
+ Could not write locale file, please make sure that config/locales exists and is writeable
+ """
+
Scenario: Running push on a file
In order to send my translations
When I have a valid project on localeapp.com with api key "MYAPIKEY"
View
@@ -57,6 +57,11 @@ def remove_child_keys!(sub_hash, keys)
# originally from ActiveSupport
def atomic_write(file_name, temp_dir = Dir.tmpdir)
+ target_dir = File.dirname(file_name)
+ unless Dir.exists?(target_dir)
+ raise "Could not write locale file, please make sure that #{target_dir} exists and is writeable"
+ end
+
temp_file = Tempfile.new(File.basename(file_name), temp_dir)
yield temp_file
temp_file.close

0 comments on commit cd368ab

Please sign in to comment.