Sha256: 7c8014ee1a0529a5208747a72ac22e02ae48cada489a205e29f59e553088602c

Contents?: true

Size: 1.26 KB

Versions: 5

Compression:

Stored size: 1.26 KB

Contents

require "spec_helper"

describe NPR::Entity::RelatedLink do
  json_fixture do
   <<-JSON
      {
        "id": "167020072",
        "type": "internal",
        "caption": {
          "$text": " Ravi Shankar At 90: The Man And His Music"
        },
        "link": [
          {
            "type": "html",
            "$text": "http://www.npr.org/2010/04/06/125507150/ravi-shankar-at-90-the-man-and-his-music?ft=3&f=167019577"
          },
          {
            "type": "api",
            "$text": "http://api.npr.org/query?id=125507150&apiKey=MDA1OTI3MjQ5MDEyODUwMTE2MzM1YzNmZA004"
          }
        ]
      }
    JSON
  end

  #----------------------------

  describe "relations" do
    it "has links" do
      related_link = NPR::Entity::RelatedLink.new(@fixture)
      related_link.links.size.should eq 2
      related_link.links.first.should be_a NPR::Entity::Link
    end
  end

  #----------------------------

  describe "attributes" do
    before :each do
      @related_link = NPR::Entity::RelatedLink.new(@fixture)
    end

    it "has a caption" do
      @related_link.caption.should match /Ravi Shankar/
    end

    it "has a type" do
      @related_link.type.should eq "internal"
    end

    it "has an id" do
      @related_link.id.should be_a Integer
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
npr-3.0.0 spec/unit/entity/related_link_spec.rb
npr-2.0.2 spec/unit/entity/related_link_spec.rb
npr-2.0.1 spec/unit/entity/related_link_spec.rb
npr-2.0.0 spec/unit/entity/related_link_spec.rb
npr-1.2.0 spec/unit/entity/related_link_spec.rb