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