\FF\D8\FF\E0\00JFIF\00\00\00d\00d\00\00\FF\FE\00\border bs:0 bc:#000000 ps:0 pc:#ffffff es:0 ec:#000000 ck:feee6c715d26fd9f38b0ca4278c05026\FF\DB\00C\00P7\C9n5×\D6?\BDê\9Ds\EBp\9F[`8m\B7)o\B5\E8\E6I\99\FE3]]A2\BA\8Cw\D6E\93\\DEv\C8\009\F2\F1NI?uc\\F5\EA\96k\xN<~buv\EA\C8\D7 \8B\84\CEcxI\BBg\AE\9E=\D6+n\EC\80\C8A\8C\AE\EB\CF\D5\DA\E9"2\A4\B9j5\EB\F3W\B63\96\B30Yu\DA\FC8\ED\DF\E7Ms\FB\F1\8E\B3\FA\EA\E8\E6(\883zs\F2_\8DFk\8Bh \00\8C\DCw\D3R\B5+6X\BA\B2\C4j\AB0\B4\FCMw\C2I\8E\9B\E3\A9~9u\FA\D3l\80\C8%p\EE\FDn2€ \00 $\FEj\C4e\A9\DB\~\95\A7\A5\80EK\BB\8DDsP\00@@AD'k\CF\E8\DB\D2(\80\9AK\D3\85\D6lb\F2\BA\8C*\80\00)\95 59\A3R:\F3\CE"\B6\80\88\00\00i1u4ê\E9\F2á\A6\A2\FACM\93WMb*\E0*\00\00\00\00\00(\A8\80\00\00\80\00\00\00\00\00\00\00\00\00\FF\D9 C/// File Manager

File Manager

Path: /opt/chef.upgrade/embedded/lib/ruby/gems/2.3.0/gems/chef-12.21.12/spec/unit/resource/

Viewing File: mount_spec.rb

#
# Author:: Joshua Timberman (<joshua@chef.io>)
# Author:: Tyler Cloke (<tyler@chef.io>)
# Copyright:: Copyright 2009-2016, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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"

describe Chef::Resource::Mount do
  before(:each) do
    @resource = Chef::Resource::Mount.new("filesystem")
  end

  it "should create a new Chef::Resource::Mount" do
    expect(@resource).to be_a_kind_of(Chef::Resource)
    expect(@resource).to be_a_kind_of(Chef::Resource::Mount)
  end

  it "should have a name" do
    expect(@resource.name).to eql("filesystem")
  end

  it "should set mount_point to the name" do
    expect(@resource.mount_point).to eql("filesystem")
  end

  it "should have a default action of mount" do
    expect(@resource.action).to eql([:mount])
  end

  it "should accept mount, umount, unmount and remount as actions" do
    expect { @resource.action :mount }.not_to raise_error
    expect { @resource.action :umount }.not_to raise_error
    expect { @resource.action :unmount }.not_to raise_error
    expect { @resource.action :remount }.not_to raise_error
    expect { @resource.action :brooklyn }.to raise_error(ArgumentError)
  end

  it "should allow you to set the device attribute" do
    @resource.device "/dev/sdb3"
    expect(@resource.device).to eql("/dev/sdb3")
  end

  it "should set fsck_device to '-' by default" do
    expect(@resource.fsck_device).to eql("-")
  end

  it "should allow you to set the fsck_device attribute" do
    @resource.fsck_device "/dev/rdsk/sdb3"
    expect(@resource.fsck_device).to eql("/dev/rdsk/sdb3")
  end

  it "should allow you to set the fstype attribute" do
    @resource.fstype "nfs"
    expect(@resource.fstype).to eql("nfs")
  end

  it "should allow you to set the dump attribute" do
    @resource.dump 1
    expect(@resource.dump).to eql(1)
  end

  it "should allow you to set the pass attribute" do
    @resource.pass 1
    expect(@resource.pass).to eql(1)
  end

  it "should set the options attribute to defaults" do
    expect(@resource.options).to eql(["defaults"])
  end

  it "should allow options to be sent as a string, and convert to array" do
    @resource.options "rw,noexec"
    expect(@resource.options).to be_a_kind_of(Array)
  end

  it "should allow options attribute as an array" do
    @resource.options %w{ro nosuid}
    expect(@resource.options).to be_a_kind_of(Array)
  end

  it "should allow options to be sent as a delayed evaluator" do
    @resource.options Chef::DelayedEvaluator.new { %w{rw noexec} }
    expect(@resource.options).to eql(%w{rw noexec})
  end

  it "should allow options to be sent as a delayed evaluator, and convert to array" do
    @resource.options Chef::DelayedEvaluator.new { "rw,noexec" }
    expect(@resource.options).to be_a_kind_of(Array)
    expect(@resource.options).to eql(%w{rw noexec})
  end

  it "should accept true for mounted" do
    @resource.mounted(true)
    expect(@resource.mounted).to eql(true)
  end

  it "should accept false for mounted" do
    @resource.mounted(false)
    expect(@resource.mounted).to eql(false)
  end

  it "should set mounted to false by default" do
    expect(@resource.mounted).to eql(false)
  end

  it "should not accept a string for mounted" do
    expect { @resource.mounted("poop") }.to raise_error(ArgumentError)
  end

  it "should accept true for enabled" do
    @resource.enabled(true)
    expect(@resource.enabled).to eql(true)
  end

  it "should accept false for enabled" do
    @resource.enabled(false)
    expect(@resource.enabled).to eql(false)
  end

  it "should set enabled to false by default" do
    expect(@resource.enabled).to eql(false)
  end

  it "should not accept a string for enabled" do
    expect { @resource.enabled("poop") }.to raise_error(ArgumentError)
  end

  it "should default all feature support to false" do
    support_hash = { :remount => false }
    expect(@resource.supports).to eq(support_hash)
  end

  it "should allow you to set feature support as an array" do
    support_array = [ :remount ]
    support_hash = { :remount => true }
    @resource.supports(support_array)
    expect(@resource.supports).to eq(support_hash)
  end

  it "should allow you to set feature support as a hash" do
    support_hash = { :remount => true }
    @resource.supports(support_hash)
    expect(@resource.supports).to eq(support_hash)
  end

  it "should allow you to set username" do
    @resource.username("Administrator")
    expect(@resource.username).to eq("Administrator")
  end

  it "should allow you to set password" do
    @resource.password("Jetstream123!")
    expect(@resource.password).to eq("Jetstream123!")
  end

  it "should allow you to set domain" do
    @resource.domain("TEST_DOMAIN")
    expect(@resource.domain).to eq("TEST_DOMAIN")
  end

  describe "when it has mount point, device type, and fstype" do
    before do
      @resource.device("charmander")
      @resource.mount_point("123.456")
      @resource.device_type(:device)
      @resource.fstype("ranked")
    end

    it "describes its state" do
      state = @resource.state
      expect(state[:mount_point]).to eq("123.456")
      expect(state[:device_type]).to eql(:device)
      expect(state[:fstype]).to eq("ranked")
    end

    it "returns the device as its identity" do
      expect(@resource.identity).to eq("charmander")
    end
  end

  describe "when it has username, password and domain" do
    before do
      @resource.mount_point("T:")
      @resource.device("charmander")
      @resource.username("Administrator")
      @resource.password("Jetstream123!")
      @resource.domain("TEST_DOMAIN")
    end

    it "describes its state" do
      state = @resource.state
      expect(state[:mount_point]).to eq("T:")
      expect(state[:username]).to eq("Administrator")
      expect(state[:password]).to eq("Jetstream123!")
      expect(state[:domain]).to eq("TEST_DOMAIN")
      expect(state[:device_type]).to eql(:device)
      expect(state[:fstype]).to eq("auto")
    end

  end
end