Sha256: 2fe26e12c0df4b0048fea65f489bd5a30de83090762bc45710ab2b88028b2dba

Contents?: true

Size: 1.64 KB

Versions: 4

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'

describe ConfigCurator::Component do
  subject(:component) { ConfigCurator::Component.new }

  describe "#install" do
    context "when component should be installed" do
      it "installs the component and returns true" do
        expect(component).to receive(:install?).and_return(true)
        expect(component).to receive(:install_component)
        expect(component).to receive(:set_mode)
        expect(component).to receive(:set_owner)
        expect(component.install).to be true
      end
    end

    context "when component should not be installed" do
      it "does not install the component and returns false" do
        expect(component).to receive(:install?).and_return(false)
        expect(component).to_not receive(:install_component)
        expect(component).to_not receive(:set_mode)
        expect(component).to_not receive(:set_owner)
        expect(component.install).to be false
      end
    end
  end

  describe "#install?" do
    context "when source not given" do
      it "fails" do
        component.destination = 'inst_path'
        expect { component.install? }.to raise_error ConfigCurator::Symlink::InstallFailed
      end
    end

    context "when destination not given" do
      it "fails" do
        component.source = 'dir'
        expect { component.install? }.to raise_error ConfigCurator::Symlink::InstallFailed
      end
    end

    context "when source does not exist" do
      it "fails" do
        component.destination = 'inst_path'
        component.source = 'dir/that/does/not/exist'
        expect { component.install? }.to raise_error ConfigCurator::Symlink::InstallFailed
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
config_curator-0.2.4 spec/units/component_spec.rb
config_curator-0.2.3 spec/units/component_spec.rb
config_curator-0.2.2 spec/units/component_spec.rb
config_curator-0.2.1 spec/units/component_spec.rb