Sha256: ec13dfc34ad98824d660604abe41bc9b8d9fe98e80e0969a925ae6e77b58994d

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

require "spec_helper"
require "json"

describe NPR::API::Response do
  before :each do
    @client = NPR::API::Client.new(:apiKey => "key")
  end

  describe "messages" do
    it "generates messages" do
      response = mock_response "json/04_invalid_id.json" do
        @client.query(:id => 999)
      end

      response.messages.size.should eq 1
      response.messages.first.id.should eq "201"
    end

    it "adds the messages association even if there aren't any" do
      response = mock_response "json/01_story_full_media.json" do
        @client.query(:id => 999)
      end

      response.messages.should eq []
    end
  end

  describe "list" do
    it "is generated" do
      response = mock_response "json/01_story_full_media.json" do
        @client.query(:id => 999)
      end

      response.list.should be_a NPR::Entity::List
    end

    it "isn't generated no list node was present" do
      response = mock_response "json/05_no_api_key.json" do
        @client.query(:id => 999)
      end

      response.list.should eq nil
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
npr-3.0.0 spec/unit/api/response_spec.rb
npr-2.0.2 spec/unit/api/response_spec.rb
npr-2.0.1 spec/unit/api/response_spec.rb
npr-2.0.0 spec/unit/api/response_spec.rb
npr-1.2.0 spec/unit/api/response_spec.rb