Sha256: 06cc2ae66fa0c27ce0d751d4d596cf0543043dc17be9470ccdeefc22d1624895

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

require 'helper'

describe Gems::Client do
  before do
    @client = Gems::Client.new
  end

  describe "#info" do
    before do
      stub_get("/api/v1/gems/rails.json").to_return(:body => fixture("rails.json"))
    end

    it "should return some basic information about the given gem" do
      info = @client.info 'rails'
      a_get("/api/v1/gems/rails.json").should have_been_made
      info.name.should == 'rails'
    end
  end

  describe "#search" do
    before do
      stub_get("/api/v1/search.json?query=cucumber").to_return(:body => fixture("search.json"))
    end

    it "should return an array of active gems that match the query" do
      search = @client.search 'cucumber'
      a_get("/api/v1/search.json?query=cucumber").should have_been_made
      search.first.name.should == 'cucumber'
    end
  end

  describe "#versions" do
    before do
      stub_get("/api/v1/versions/coulda.json").to_return(:body => fixture("coulda.json"))
    end

    it "should return an array of gem version details" do
      versions = @client.versions 'coulda'
      a_get("/api/v1/versions/coulda.json").should have_been_made
      versions.first.number.should == '0.6.3'
    end
  end

  describe "#dependencies" do
    before do
      stub_get("/api/v1/versions/coulda-0.6.3/downloads.json").to_return(:body => fixture("downloads.json"))
    end

    it "should return the number of downloads by day for a particular gem version" do
      downloads = @client.downloads 'coulda', '0.6.3'
      a_get("/api/v1/versions/coulda-0.6.3/downloads.json").should have_been_made
      downloads["2011-11-01"].should == 0
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gems-0.0.2 spec/gems/client_spec.rb