Skip to content

Commit

Permalink
Device locale can now be set
Browse files Browse the repository at this point in the history
  • Loading branch information
luizmb committed Apr 13, 2018
1 parent bbb47b5 commit d54806f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/simctl/device_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,14 @@ def set_language(language)
plist[key].unshift(language).uniq!
end
end

# Sets the device locale
#
# @return [void]
def set_locale(locale)
edit_plist(path.global_preferences_plist) do |plist|
plist['AppleLocale'] = locale
end
end
end
end
13 changes: 13 additions & 0 deletions spec/simctl/device_interaction_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'cfpropertylist'
require 'securerandom'
require 'spec_helper'

Expand Down Expand Up @@ -94,6 +95,18 @@
describe 'setting the device language' do
it 'sets the device language' do
@device.settings.set_language('de')
plist = CFPropertyList::List.new(file: @device.path.global_preferences_plist)
content = CFPropertyList.native_types(plist.value)
expect(content['AppleLanguages']).to include('de')
end
end

describe 'setting the device locale' do
it 'sets the device locale' do
@device.settings.set_locale('en_DE')
plist = CFPropertyList::List.new(file: @device.path.global_preferences_plist)
content = CFPropertyList.native_types(plist.value)
expect(content['AppleLocale']).to be == 'en_DE'
end
end
end
Expand Down

0 comments on commit d54806f

Please sign in to comment.