Sha256: 781a77aa5ec5b592f7e96f95591ff21bbebca949954b36f3adb5254a3be44bab

Contents?: true

Size: 1.81 KB

Versions: 2

Compression:

Stored size: 1.81 KB

Contents

require 'spec_helper'

module Omnibus
  describe Builder do
    let(:software) do
      double(Software,
        name: 'chefdk',
        install_dir: '/opt/chefdk',
        project_dir: '/opt/chefdk',
      )
    end

    subject { described_class.new(software) }

    context 'DSL methods' do
      before do
        allow(subject).to receive(:find_file).and_return([nil, '/path'])
      end

      it_behaves_like 'a cleanroom setter', :command, %|command 'echo "hello"'|
      it_behaves_like 'a cleanroom setter', :patch, %|patch source: 'diff.patch'|
      it_behaves_like 'a cleanroom getter', :max_build_jobs
      it_behaves_like 'a cleanroom setter', :ruby, %|ruby '-e "puts"'|
      it_behaves_like 'a cleanroom setter', :gem, %|gem 'install bacon'|
      it_behaves_like 'a cleanroom setter', :bundle, %|bundle 'install'|
      it_behaves_like 'a cleanroom setter', :block, <<-EOH.gsub(/^ {8}/, '')
        block 'A named block' do
          # Complex operation
        end
      EOH
      it_behaves_like 'a cleanroom setter', :erb,  <<-EOH.gsub(/^ {8}/, '')
        erb source: 'template.erb',
            dest: '/path/to/file',
            vars: { a: 'b', c: 'd' }
      EOH
      it_behaves_like 'a cleanroom setter', :mkdir, %|mkdir 'path'|
      it_behaves_like 'a cleanroom setter', :touch, %|touch 'file'|
      it_behaves_like 'a cleanroom setter', :delete, %|delete 'file'|
      it_behaves_like 'a cleanroom setter', :copy, %|copy 'file', 'file2'|
      it_behaves_like 'a cleanroom setter', :move, %|move 'file', 'file2'|
      it_behaves_like 'a cleanroom setter', :link, %|link 'file', 'file2'|
      it_behaves_like 'a cleanroom getter', :project_root, %|puts project_root|

      # From software
      it_behaves_like 'a cleanroom getter', :project_dir
      it_behaves_like 'a cleanroom getter', :install_dir
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
omnibus-3.2.0.rc.3 spec/unit/builder_spec.rb
omnibus-3.2.0.rc.2 spec/unit/builder_spec.rb