Sha256: e3a9c92e86ceb43f1d7dec4ad75db00995f7abeb718d7419dd5b1ab44ce74795

Contents?: true

Size: 1.28 KB

Versions: 4

Compression:

Stored size: 1.28 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

4 entries across 4 versions & 1 rubygems

Version Path
npr-1.1.0 spec/unit/entity/related_link_spec.rb
npr-0.1.2 spec/unit/entity/related_link_spec.rb
npr-0.1.1 spec/unit/entity/related_link_spec.rb
npr-0.1.0 spec/unit/entity/related_link_spec.rb