Sha256: c5eb5ea503aa5d9b131c1b29cbdb52ef7b0d92f303bad3517ee871e1d8b656ff

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

require_relative '../spec_helper'

require 'wright/resource/package'

describe Wright::Resource::Package do
  before(:each) do
    @package = Wright::Resource::Package.new('foo')
    @provider = Minitest::Mock.new
    @package.instance_variable_set(:@provider, @provider)
  end

  describe '#initialize' do
    it 'should accept attributes via an argument hash' do
      resource = Wright::Resource::Package.new('sample_name',
                                               version: 'sample_version',
                                               options: 'sample_options',
                                               action: 'sample_action')
      resource.name.must_equal 'sample_name'
      resource.version.must_equal 'sample_version'
      resource.options.must_equal 'sample_options'
      resource.action.must_equal 'sample_action'
    end
  end

  describe '#installed_versions' do
    it 'should ask the provider for installed versions' do
      @provider.expect(:installed_versions, nil)
      @package.installed_versions
      @provider.verify
    end
  end

  describe '#installed?' do
    it 'should ask the provider for the install status' do
      @provider.expect(:installed?, nil)
      @package.installed?
      @provider.verify
    end
  end

  describe '#install' do
    it 'should ask the provider to install the package' do
      @provider.expect(:install, nil)
      @provider.expect(:updated?, true)
      @package.install
      @provider.verify
    end
  end

  describe '#remove' do
    it 'should ask the provider to remove the package' do
      @provider.expect(:remove, nil)
      @provider.expect(:updated?, true)
      @package.remove
      @provider.verify
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wright-0.5.0 spec/resource/package_spec.rb