Sha256: defc1d5d18be3fae60b5e248652aaae49a62ed7872e42249c53fc4d830bca31d

Contents?: true

Size: 1021 Bytes

Versions: 1

Compression:

Stored size: 1021 Bytes

Contents

require 'spec_helper'

describe Popularity::Medium do
  context "non-medium url" do
    use_vcr_cassette "medium-invalid"

    subject {
      Popularity::Medium.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 "medium url" do
    use_vcr_cassette "medium-valid"

    subject {
      Popularity::Medium.new('https://medium.com/@jeffkeen/call-me-sometime-64ed463c02f0')
    }

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

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

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

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

      it "should have required attributes in json" do
        expect(subject.recommends).to eq(json["recommends"])
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
popularity-0.2.1 spec/medium_spec.rb