Sha256: 040a8f8c71578baef3ce5dc69009fb8ea59c3faeceafbc0dac57e2937853d47e

Contents?: true

Size: 1.56 KB

Versions: 8

Compression:

Stored size: 1.56 KB

Contents

require "spec_helper"

describe "bundle open" do
  before :each do
    install_gemfile <<-G
      source "file://#{gem_repo1}"
      gem "rails"
    G
  end

  it "opens the gem with BUNDLER_EDITOR as highest priority" do
    bundle "open rails", :env => {"EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "echo bundler_editor"}
    expect(out).to eq("bundler_editor #{default_bundle_path('gems', 'rails-2.3.2')}")
  end

  it "opens the gem with VISUAL as 2nd highest priority" do
    bundle "open rails", :env => {"EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => ""}
    expect(out).to eq("visual #{default_bundle_path('gems', 'rails-2.3.2')}")
  end

  it "opens the gem with EDITOR as 3rd highest priority" do
    bundle "open rails", :env => {"EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => ""}
    expect(out).to eq("editor #{default_bundle_path('gems', 'rails-2.3.2')}")
  end

  it "complains if no EDITOR is set" do
    bundle "open rails", :env => {"EDITOR" => "", "VISUAL" => "", "BUNDLER_EDITOR" => ""}
    expect(out).to eq("To open a bundled gem, set $EDITOR or $BUNDLER_EDITOR")
  end

  it "complains if gem not in bundle" do
    bundle "open missing", :env => {"EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => ""}
    expect(out).to match(/could not find gem 'missing'/i)
  end

  it "suggests alternatives for similar-sounding gems" do
    bundle "open Rails", :env => {"EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => ""}
    expect(out).to match(/did you mean rails\?/i)
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
bundler-1.3.0.pre.8 spec/other/open_spec.rb
bundler-1.3.0.pre.7 spec/other/open_spec.rb
bundler-1.3.0.pre.6 spec/other/open_spec.rb
bundler-1.3.0.pre.5 spec/other/open_spec.rb
bundler-1.3.0.pre.4 spec/other/open_spec.rb
bundler-1.3.0.pre.3 spec/other/open_spec.rb
bundler-1.3.0.pre.2 spec/other/open_spec.rb
bundler-1.3.0.pre spec/other/open_spec.rb