From be1191b72d72887713048538e72a11b3940c6eb8 Mon Sep 17 00:00:00 2001 From: Kapil Chouhan Date: Fri, 10 Apr 2020 09:07:08 +0000 Subject: Update the locale resource to support Windows Signed-off-by: Kapil Chouhan --- spec/functional/resource/locale_spec.rb | 14 ++++++++++++-- spec/unit/resource/locale_spec.rb | 34 --------------------------------- 2 files changed, 12 insertions(+), 36 deletions(-) (limited to 'spec') diff --git a/spec/functional/resource/locale_spec.rb b/spec/functional/resource/locale_spec.rb index 29cd01ad78..24a43ef0ba 100644 --- a/spec/functional/resource/locale_spec.rb +++ b/spec/functional/resource/locale_spec.rb @@ -74,8 +74,7 @@ describe Chef::Resource::Locale, :requires_root do resource.lang resource.lc_env resource.run_action(:update) - unsets_system_locale("LANG=en_US", "LC_TIME=en_IN") - sets_system_locale("") + expect(resource).not_to be_updated_by_last_action end end end @@ -94,4 +93,15 @@ describe Chef::Resource::Locale, :requires_root do expect { resource.run_action(:update) }.to raise_error(Chef::Exceptions::ProviderNotFound) end end + + context "on windows", :windows_only, requires_root: false do + describe "action: update" do + context "Sets system locale" do + it "when lang is given" do + resource.lang("en-US") + resource.run_action(:update) + end + end + end + end end diff --git a/spec/unit/resource/locale_spec.rb b/spec/unit/resource/locale_spec.rb index 7f70905ff0..e1275a6830 100644 --- a/spec/unit/resource/locale_spec.rb +++ b/spec/unit/resource/locale_spec.rb @@ -186,38 +186,4 @@ describe Chef::Resource::Locale do end end end - - describe "#up_to_date?" do - context "when file does not exists" do - it "returns false" do - allow(File).to receive(:read).and_raise(Errno::ENOENT, "No such file or directory") - expect(provider.up_to_date?).to be_falsy - end - end - - context "when file exists" do - let(:content) { "LANG=en_US\nLC_MESSAGES=en_AG.utf8\nLC_TIME=en_AG.utf8\n" } - before do - allow(provider).to receive(:new_content).and_return(content) - end - context "but is empty" do - it "returns false" do - allow(File).to receive(:read).and_return("") - expect(provider.up_to_date?).to be_falsy - end - end - context "and contains old key-vals" do - it "returns false" do - allow(File).to receive(:read).and_return("LC_MESSAGES=en_AG.utf8\n") - expect(provider.up_to_date?).to be_falsy - end - end - context "and contains new key-vals" do - it "returns true" do - allow(File).to receive(:read).and_return(content) - expect(provider.up_to_date?).to be_truthy - end - end - end - end end -- cgit v1.2.1