Sha256: 1dfbfebad43eb78cf61c48f2bd1d60e810342cce6d4ed84e5753f17de1adfb80

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

include Rake

describe Rake::Funnel::Tasks::BinPath do
  before {
    Task.clear
    expect(subject).to be
  }

  describe 'defaults' do
    its(:name) { should == :bin_path }
    its(:search_pattern) { should eq(%w(tools/* tools/*/bin packages/**/tools)) }
  end

  describe 'execution' do
    before {
      allow(ENV).to receive(:[]).with('PATH').and_return('default PATH contents')
      allow(ENV).to receive(:[]=)
      allow(Rake).to receive(:rake_output_message)
    }

    before {
      subject.search_pattern = %w(foo bar)

      allow(Dir).to receive(:[]).with(*subject.search_pattern).and_return(subject.search_pattern)

      Task[:bin_path].invoke
    }

    it 'should prepend sorted matching folders to the PATH environment variable' do
      paths = subject.search_pattern.sort.map { |path| File.expand_path(path) } << ENV['PATH']

      expect(ENV).to have_received(:[]=).with('PATH', paths.join(File::PATH_SEPARATOR))
    end

    it 'should report added paths' do
      expect(Rake).to have_received(:rake_output_message).with(%r|/foo$|)
      expect(Rake).to have_received(:rake_output_message).with(%r|/bar$|)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rake-funnel-0.1.0.pre spec/rake/funnel/tasks/bin_path_spec.rb