Sha256: 7b4e5ca7d572e8910057bb35c9ca614e539348c2b7a32ebc8aa6f2a678b65cc1

Contents?: true

Size: 977 Bytes

Versions: 1

Compression:

Stored size: 977 Bytes

Contents

describe CLIForge, ".caller_path" do

  def spec_caller_line
    caller.first
  end

  it "should extract the current platform's stack format" do
    caller_line = spec_caller_line
    path        = described_class.caller_path(caller_line)

    expect(path).to eq(File.dirname(__FILE__)), "Extracted #{path.inspect} from #{caller_line.inspect}"
  end

  it "should extract paths from well formed MRI stack lines" do
    path = described_class.caller_path("/usr/bin/foo:6:in `<main>'")

    expect(path).to eq("/usr/bin")
  end

  it "should expand relative paths" do
    path = described_class.caller_path("bin/bar:6:in `<main>'")

    expect(path).to eq(File.expand_path("bin"))
  end

  it "should not freak out if given nil" do
    path = described_class.caller_path(nil)

    expect(path).to eq(nil)
  end

  it "should not expose fake paths as the current path" do
    path = described_class.caller_path("(irb):3:in `irb_binding'")

    expect(path).to eq(nil)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cli-forge-0.1.0 spec/unit/cli_forge/class_methods/caller_path_spec.rb