Sha256: 832a132837654d883e1ff9f18335fd704f1ec2d4ea1c8919c5cfd551de7238e5

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'

describe Popularity::Rubygems do
  context "non-rubygems url" do
    use_vcr_cassette "rubygems-invalid"

    subject {
      Popularity::Rubygems.new('http://google.com')
    }

    it "should be invalid" do
      expect(subject.valid?).to eq(false)
    end

    it "should have no resposne" do
      expect(subject.response).to eq(false)
    end
  end

  context "rubygems url" do
    use_vcr_cassette "rubygems-valid"

    subject {
      Popularity::Rubygems.new('https://rubygems.org/gems/popularity')
    }

    it "should be valid" do
      expect(subject.valid?).to be_truthy
    end

    it "should have response" do
      expect(subject.response).to_not eq(false)
    end

    it "should have correct number of downloads" do
      expect(85).to eq(subject.downloads)
    end

    context "json" do
      let(:json) { subject.to_json }

      it "should have required attributes in json" do 
        [:downloads].each do |att|
          expect(subject.send(att)).to eq(json[att.to_s])
        end
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
popularity-0.1.1 spec/rubygems_spec.rb
popularity-0.1.0 spec/rubygems_spec.rb