Sha256: e4b67334218d55af60d4f86170669e998210b284f40145952b1ed34fb560a81b

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'

describe TedApi::Client::Speakers do

  after(:each) do
    TedApi.reset
  end

  # JSON Tests:

  it "should list speakers in json" do
    @client = TedApi::Client.new(api_key: 'foo')
    stub_get("speakers.json?api-key=foo").
      to_return(:body => fixture("speakers.json"))
    response = @client.speakers
    response.speakers.first.speaker.description.should == 'Climate-change prophet'
  end 
  
  it "should return a specific speaker in json" do
    @client = TedApi::Client.new(api_key: 'foo')
    stub_get("speakers/2.json?api-key=foo").
      to_return(:body => fixture("speaker.json"))
    response = @client.speakers('2')
    response.speaker.description.should == 'Climate-change prophet'
  end 
  
  # XML Tests:
  
  it "should list speakers in xml" do
    @client = TedApi::Client.new(api_key: 'foo', response_format: 'xml')
    stub_get("speakers.xml?api-key=foo").
      to_return(:body => fixture("speakers.xml"))
    response = @client.speakers
    response.speakers.first.first.should == 'speaker'
  end
  
  it "should return a specific theme in xml" do
    @client = TedApi::Client.new(api_key: 'foo', response_format: 'xml')
    stub_get("speakers/2.xml?api-key=foo").
      to_return(:body => fixture("speaker.xml"))
    response = @client.speakers('2')
    response.speaker.description.should == 'Climate-change prophet'
  end
  
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

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