Sha256: d74c984686bcbb45fbbf810c423e7f77e8a175c8674160396655b9f91f38adf3

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

require File.expand_path('../../../../lib/bubble-wrap/requirement/path_manipulation', __FILE__)

describe BubbleWrap::Requirement::PathManipulation do

  subject do
    o = Object.new
    o.extend BubbleWrap::Requirement::PathManipulation
    o
  end

  describe '#convert_caller_to_path' do
    it 'strips off from the second-to-last colon' do
      subject.convert_caller_to_path("/fake/:path:91:in `fake_method'").
        should == '/fake/:path'
    end

    it 'leaves plain old paths unmolested' do
      subject.convert_caller_to_path("/fake/path").
        should == '/fake/path'
    end
  end

  describe '#convert_to_absolute_path' do
    it 'converts relative paths to absolute paths' do
      subject.convert_to_absolute_path('foo')[0].should == '/'
    end

    it "doesn't modify absolute paths" do
      subject.convert_to_absolute_path('/foo').should == '/foo'
    end
  end

  describe '#strip_up_to_last_lib' do
    it 'strips off from the last lib' do
      subject.strip_up_to_last_lib('/fake/lib/dir/lib/foo').
        should == '/fake/lib/dir'
    end

    it "doesn't modify the path otherwise" do
      subject.strip_up_to_last_lib('/fake/path').
        should == '/fake/path'
    end
  end

  describe "#convert_to_relative" do
    it 'strips off the root portion' do
      subject.convert_to_relative('/foo/bar/baz', '/foo').
        should == 'bar/baz'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bubble-wrap-0.4.0 lib_spec/bubble-wrap/requirement/path_manipulation_spec.rb