diff options
author | Ho-Sheng Hsiao <hosheng.hsiao@gmail.com> | 2012-03-23 17:05:21 -0400 |
---|---|---|
committer | Ho-Sheng Hsiao <hosheng.hsiao@gmail.com> | 2012-03-23 17:05:21 -0400 |
commit | df223152654134b61aa22bf30985893eb4c362de (patch) | |
tree | 2abcc91d98581d59ba75fc34d829728669200c8e /spec | |
parent | 6761ca339af8a350a4424224677e05d986fa94b2 (diff) | |
download | mixlib-shellout-df223152654134b61aa22bf30985893eb4c362de.tar.gz |
[RSPEC] Refactored spec for setting LC_ALL to nil
Diffstat (limited to 'spec')
-rw-r--r-- | spec/mixlib/shellout/shellout_spec.rb | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/spec/mixlib/shellout/shellout_spec.rb b/spec/mixlib/shellout/shellout_spec.rb index 902fe2b..651b1ea 100644 --- a/spec/mixlib/shellout/shellout_spec.rb +++ b/spec/mixlib/shellout/shellout_spec.rb @@ -306,18 +306,28 @@ describe Mixlib::ShellOut do end end - it "does not set any locale when the user gives LC_ALL => nil" do - # kinda janky - cmd = Mixlib::ShellOut.new(ECHO_LC_ALL, :environment => {"LC_ALL" => nil}) - cmd.run_command - if !ENV['LC_ALL'] && windows? - expected = "%LC_ALL%" - else - expected = ENV['LC_ALL'].to_s.strip + context 'with LC_ALL set to nil' do + let(:shell_cmd) { Mixlib::ShellOut.new(cmd, :environment => {"LC_ALL" => nil}) } + + context 'when running under Unix', :unix_only => true do + let(:parent_locale) { ENV['LC_ALL'].to_s.strip } + + it "should use the parent process's locale" do + should eql(parent_locale) + end end - cmd.stdout.strip.should == expected - end + context 'when running under Windows', :windows_only => true do + # FIXME: I don't understand the original: + # https://github.com/opscode/mixlib-shellout/blob/7a1fd26ab7c74023e044bfa306dff3d6b1de3d99/spec/mixlib/shellout/shellout_spec.rb#L316 + # Is it saying that under Windows, ENV['LC_ALL'] can have something, otherwise if blank, it will be '%LC_ALL%'? + let(:parent_locale) { (ENV['LC_ALL'] || '%LC_ALL%').to_s.strip } + + it "should use the parent process's locale" do + should eql(parent_locale) + end + end + end end context "with a live stream" do |