Sha256: 93c9f46341aeb592e906cb84f56379e87315718fa755db7e122df2db856851bb

Contents?: true

Size: 1.69 KB

Versions: 3

Compression:

Stored size: 1.69 KB

Contents

require "spec_helper"

describe "bpm push" do
  let(:api_key) { "deadbeef" }
  let(:creds)   { bpm_dir("credentials") }

  before do
    goto_home
    set_host
    start_fake(FakeGemcutter.new(api_key))
  end

  context "with a good api key" do
    before do
      write_api_key(api_key)
    end

    it "registers a gem when sent with the right api key" do
      bpm "push", "../../spec/fixtures/rake-0.8.7.bpkg"

      stdout.read.should include("Successfully registered rake (0.8.7)")
    end
  end

  it "shows rejection message if wrong api key is supplied" do
    write_api_key("beefbeef")

    bpm "push", "../../spec/fixtures/rake-0.8.7.bpkg"

    stdout.read.should include("One cannot simply walk into Mordor!")
  end
end

describe "bpm push without api key" do
  before do
    cd(home)
    env["HOME"] = home.to_s
    env["RUBYGEMS_HOST"] = "http://localhost:9292"
    write_api_key("beefbeef")
  end

  it "ignores files that don't exist" do
    bpm "push", "rake-1.0.0.bpkg"

    stdout.read.should include("No such file")
  end

  it "must push a valid gem" do
    bpm "push", "../../spec/fixtures/badrake-0.8.7.bpkg"

    stdout.read.should include("There was a problem opening your package.")
  end

  it "does not allow pushing of random files" do
    bpm "push", "../../Rakefile"

    stdout.read.should include("There was a problem opening your package.")
  end
end

describe "bpm push without api key" do
  before do
    cd(home)
    env["HOME"] = home.to_s
    env["RUBYGEMS_HOST"] = "http://localhost:9292"
  end

  it "asks for login first if api key does not exist" do
    bpm "push", "../../spec/fixtures/rake-0.8.7.bpkg"

    stdout.read.should include("Please login first with `bpm login`")
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bpm-0.1.4 spec/cli/push_spec.rb
bpm-0.1.3 spec/cli/push_spec.rb
bpm-0.1.2 spec/cli/push_spec.rb