Sha256: bd84a03f86cd56941d0ba7feea8803b2d56fb3ec5041488549fce90c6c71349f

Contents?: true

Size: 1.37 KB

Versions: 15

Compression:

Stored size: 1.37 KB

Contents

include Rake

describe Rake::Funnel::Tasks::BinPath do
  before {
    Task.clear
  }

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

  describe 'execution' do
    let(:default_path) { 'default PATH contents' }
    let(:search_pattern) { %w(foo bar) }

    before {
      allow(ENV).to receive(:[]).with('PATH').and_return(default_path)
      allow(ENV).to receive(:[]=)
      allow(Rake).to receive(:rake_output_message)
    }

    before {
      allow(Dir).to receive(:[]).with(*search_pattern).and_return(search_pattern)
    }

    subject {
      described_class.new do |t|
        t.search_pattern = search_pattern
      end
    }

    before {
      Task[subject.name].invoke
    }

    it 'should prepend sorted matching folders to the PATH environment variable' do
      paths = search_pattern.map { |path| File.expand_path(path) }.sort.join(File::PATH_SEPARATOR)

      expect(ENV).to have_received(:[]=).with('PATH',/^#{paths}/)
    end

    it 'should append original PATH environment variable' do
      expect(ENV).to have_received(:[]=).with('PATH', /#{default_path}$/)
    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

15 entries across 15 versions & 1 rubygems

Version Path
rake-funnel-0.16.0 spec/rake/funnel/tasks/bin_path_spec.rb
rake-funnel-0.15.0.pre spec/rake/funnel/tasks/bin_path_spec.rb
rake-funnel-0.14.0.pre spec/rake/funnel/tasks/bin_path_spec.rb
rake-funnel-0.13.0.pre spec/rake/funnel/tasks/bin_path_spec.rb
rake-funnel-0.12.0.pre spec/rake/funnel/tasks/bin_path_spec.rb
rake-funnel-0.11.0.pre spec/rake/funnel/tasks/bin_path_spec.rb
rake-funnel-0.10.0.pre spec/rake/funnel/tasks/bin_path_spec.rb
rake-funnel-0.9.1.pre spec/rake/funnel/tasks/bin_path_spec.rb
rake-funnel-0.9.0.pre spec/rake/funnel/tasks/bin_path_spec.rb
rake-funnel-0.8.0.pre spec/rake/funnel/tasks/bin_path_spec.rb
rake-funnel-0.7.0.pre spec/rake/funnel/tasks/bin_path_spec.rb
rake-funnel-0.6.1.pre spec/rake/funnel/tasks/bin_path_spec.rb
rake-funnel-0.6.0.pre spec/rake/funnel/tasks/bin_path_spec.rb
rake-funnel-0.5.0.pre spec/rake/funnel/tasks/bin_path_spec.rb
rake-funnel-0.4.0.pre spec/rake/funnel/tasks/bin_path_spec.rb