Sha256: ff6f06a15e32bb6d8d56860b19e8977b6ed54e2754a29350f31610478d437a07

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe Zelda::Request do
  it "should call HTTParty" do
    HTTParty.should_receive(:get).with("http://zelda.omroep.nl/12345/foo").and_return nil
    Zelda::Request.get('foo')
  end

  it "should remove private attributes" do
    attrs = { 'foo' => "bar", 'created_at' => "foo", 'updated_at' => "bar", 'id' => 10 }
    HTTParty.stub!(:get).and_return(attrs)
    
    attrs = Zelda::Request.get('foo')
    
    attrs['created_at'].should be_nil
    attrs['updated_at'].should be_nil
    attrs['id'].should be_nil
    attrs['foo'].should == 'bar'
  end

  it "should raise an error without an API key" do
    api_key = Zelda.send(:remove_const, :API_KEY)
    lambda { Zelda::Request.get('foo') }.should raise_error("No Zelda::API_KEY specified")
    Zelda::API_KEY = api_key
  end
  
  describe "when returning an url" do
    it "should be correct with 1 args" do
      Zelda::Request.parse_url('foo').should == "http://zelda.omroep.nl/12345/foo" 
    end
    
    it "should be correct with 2 args" do
      Zelda::Request.parse_url('foo', 'bar').should == "http://zelda.omroep.nl/12345/foo/bar" 
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
bartzon-zelda-0.0.5 spec/zelda/request_spec.rb
zelda-0.1.0 spec/zelda/request_spec.rb