Sha256: 938c2b38ed07312dda2751d4d8711fbe2701d5f56152f3aa24b159578a8aaeb3

Contents?: true

Size: 1.11 KB

Versions: 6

Compression:

Stored size: 1.11 KB

Contents

require '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

6 entries across 6 versions & 1 rubygems

Version Path
zelda-1.3.0 spec/zelda/request_spec.rb
zelda-1.2.1 spec/zelda/request_spec.rb
zelda-1.2.0 spec/zelda/request_spec.rb
zelda-1.1.1 spec/zelda/request_spec.rb
zelda-1.1.0 spec/zelda/request_spec.rb
zelda-1.0.0 spec/zelda/request_spec.rb