spec/rake/funnel/tasks/bin_path_spec.rb in rake-funnel-0.17.0 vs spec/rake/funnel/tasks/bin_path_spec.rb in rake-funnel-0.18.0

- old
+ new

@@ -10,11 +10,15 @@ 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) } + let(:search_pattern) { %w(foo bar not-a-directory) } + let(:directories) { search_pattern.first(2) + .map { |path| File.expand_path(path) } + .sort + .join(File::PATH_SEPARATOR) } let(:path_modifier) { nil } before { allow(ENV).to receive(:[]).with('PATH').and_return(default_path) allow(ENV).to receive(:[]=) @@ -29,19 +33,23 @@ } context 'paths to add' do before { allow(Dir).to receive(:[]).with(*search_pattern).and_return(search_pattern) + allow(File).to receive(:directory?).and_return(true) + allow(File).to receive(:directory?).with(search_pattern.last).and_return(false) } 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', /^#{directories}/) + end - expect(ENV).to have_received(:[]=).with('PATH',/^#{paths}/) + it 'should reject files' do + expect(ENV).not_to have_received(:[]=).with('PATH', /#{search_pattern.last}/) end it 'should append original PATH environment variable' do expect(ENV).to have_received(:[]=).with('PATH', /#{default_path}$/) end