Sha256: 5095d1c21c2225e49e36860768ad438c72696fc2e1f28a43a5790d2dbe1f4a4c

Contents?: true

Size: 1.65 KB

Versions: 5

Compression:

Stored size: 1.65 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

5 entries across 5 versions & 1 rubygems

Version Path
config_curator-0.2.0 spec/units/component_spec.rb
config_curator-0.1.1 spec/units/component_spec.rb
config_curator-0.1.0 spec/units/component_spec.rb
config_curator-0.0.2 spec/units/component_spec.rb
config_curator-0.0.1 spec/units/component_spec.rb