Sha256: b3e537128c29ca887d9fccb701c34fcd9af662d18601689414a939e251e2dc45

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'

describe TedApi::Client::Countries do

  after(:each) do
    TedApi.reset
  end

  # JSON Tests:

  it "should list countries in json" do
    @client = TedApi::Client.new(api_key: 'foo')
    stub_get("countries.json?api-key=foo").
      to_return(:body => fixture("countries.json"))
    response = @client.countries
    response.states.first.state.name.should == 'Afghanistan'
  end 
  
  it "should return a specific Ted event in json" do
    @client = TedApi::Client.new(api_key: 'foo')
    stub_get("countries/1.json?api-key=foo").
      to_return(:body => fixture("country.json"))
    response = @client.countries('1')
    response.state.name.should == 'Afghanistan'
  end 
  
  # XML Tests:
  
  it "should list Ted events in xml" do
    @client = TedApi::Client.new(api_key: 'foo', response_format: 'xml')
    stub_get("countries.xml?api-key=foo").
      to_return(:body => fixture("countries.xml"))
    response = @client.countries
    response.counts.total.should == "248"
  end
  
  it "should return a specific Ted event in xml" do
    @client = TedApi::Client.new(api_key: 'foo', response_format: 'xml')
    stub_get("countries/1.xml?api-key=foo").
      to_return(:body => fixture("country.xml"))
    response = @client.countries('1')
    response.state.name.should == 'Afghanistan'
  end
  
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ted_api-0.1 spec/ted_api/client/countries_spec.rb