spec/unit/helpers_spec.rb in chef-dk-1.2.22 vs spec/unit/helpers_spec.rb in chef-dk-1.3.40

- old
+ new

@@ -13,12 +13,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # -require 'spec_helper' -require 'chef-dk/helpers' +require "spec_helper" +require "chef-dk/helpers" describe ChefDK::Helpers do let (:helpers) do ChefDK::Helpers.send(:reset!) @@ -33,88 +33,88 @@ env[k] end allow(Chef::Platform).to receive(:windows?).and_return(false) end - context 'when CHEFDK_HOME is set' do - let(:env) { {'CHEFDK_HOME' => 'foo' } } + context "when CHEFDK_HOME is set" do + let(:env) { { "CHEFDK_HOME" => "foo" } } it "returns CHEFDK_HOME" do - expect(helpers.chefdk_home).to eq(env['CHEFDK_HOME']) + expect(helpers.chefdk_home).to eq(env["CHEFDK_HOME"]) end end - context 'when CHEFDK_HOME is not set' do - context 'on windows' do + context "when CHEFDK_HOME is not set" do + context "on windows" do before do allow(Chef::Platform).to receive(:windows?).and_return(true) end - let(:env) { { 'LOCALAPPDATA' => 'C:\\foo' } } + let(:env) { { "LOCALAPPDATA" => 'C:\\foo' } } - it 'uses LOCALAPPDATA' do - expect(File).to receive(:join).with(env['LOCALAPPDATA'], 'chefdk').and_return('chefdkdefaulthome') - expect(helpers.chefdk_home).to eq('chefdkdefaulthome') + it "uses LOCALAPPDATA" do + expect(File).to receive(:join).with(env["LOCALAPPDATA"], "chefdk").and_return("chefdkdefaulthome") + expect(helpers.chefdk_home).to eq("chefdkdefaulthome") end end - context 'on *nix' do - it 'uses LOCALAPPDATA' do - expect(File).to receive(:expand_path).with('~/.chefdk').and_return('chefdkdefaulthome') - expect(helpers.chefdk_home).to eq('chefdkdefaulthome') + context "on *nix" do + it "uses LOCALAPPDATA" do + expect(File).to receive(:expand_path).with("~/.chefdk").and_return("chefdkdefaulthome") + expect(helpers.chefdk_home).to eq("chefdkdefaulthome") end end end - context 'using usr_bin_prefix' do + context "using usr_bin_prefix" do before do - stub_const('RUBY_PLATFORM', ruby_platform_string) + stub_const("RUBY_PLATFORM", ruby_platform_string) end - context 'on Mac' do - let(:ruby_platform_string) { 'x86_64-darwin12.0' } + context "on Mac" do + let(:ruby_platform_string) { "x86_64-darwin12.0" } - it 'uses /usr/local/bin' do - expect(helpers.usr_bin_prefix).to eq('/usr/local/bin') - expect(helpers.usr_bin_path('berks')).to eq('/usr/local/bin/berks') + it "uses /usr/local/bin" do + expect(helpers.usr_bin_prefix).to eq("/usr/local/bin") + expect(helpers.usr_bin_path("berks")).to eq("/usr/local/bin/berks") end end - context 'on other systems' do - let(:ruby_platform_string) { 'x86_64-linux' } + context "on other systems" do + let(:ruby_platform_string) { "x86_64-linux" } - it 'uses /usr/bin' do - expect(helpers.usr_bin_prefix).to eq('/usr/bin') - expect(helpers.usr_bin_path('berks')).to eq('/usr/bin/berks') + it "uses /usr/bin" do + expect(helpers.usr_bin_prefix).to eq("/usr/bin") + expect(helpers.usr_bin_path("berks")).to eq("/usr/bin/berks") end end end end describe "omnibus_env" do let(:git_tools_path) { File.join("embedded", "git", "usr", "bin") } let(:custom_gitbin_path) { File.join("gitbin") } before do - allow(helpers).to receive(:omnibus_expand_path) {|*paths| File.expand_path(File.join(paths)) } + allow(helpers).to receive(:omnibus_expand_path) { |*paths| File.expand_path(File.join(paths)) } allow(Dir).to receive(:exists?).with(/#{custom_gitbin_path}/).and_return false allow(Dir).to receive(:exists?).with(/#{git_tools_path}/).and_return false end it "does not include the git tools in the path" do - expect(helpers.omnibus_env['PATH']).to_not match(/#{git_tools_path}/) + expect(helpers.omnibus_env["PATH"]).to_not match(/#{git_tools_path}/) end context "when the custom gitbin directory exists" do it "includes them in the path" do expect(Dir).to receive(:exists?).with(/#{custom_gitbin_path}/).and_return true - expect(helpers.omnibus_env['PATH']).to match(/#{custom_gitbin_path}$/) + expect(helpers.omnibus_env["PATH"]).to match(/#{custom_gitbin_path}$/) end end context "when the git tools directory exists" do it "includes them in the path" do expect(Dir).to receive(:exists?).with(/#{git_tools_path}/).and_return true - expect(helpers.omnibus_env['PATH']).to match(/#{git_tools_path}$/) + expect(helpers.omnibus_env["PATH"]).to match(/#{git_tools_path}$/) end end end end