Sha256: ed7a5c05ba198c560b99a92a86b804ead5dc0fe855e6fea5e08b49401ec953ea

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

require 'spec_helper'

describe TedApi::Client::Events do

  after(:each) do
    TedApi.reset
  end

  # JSON Tests:

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

Version data entries

1 entries across 1 versions & 1 rubygems

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