Sha256: 52faa7ef30c314f4c2162351ecbbebd5eff14da4f55b31f290e5d7e106368dfc

Contents?: true

Size: 892 Bytes

Versions: 1

Compression:

Stored size: 892 Bytes

Contents

require 'spec_helper'

describe Sensis do
  
  context "using sensis search" do

    before do
      @api_key = Sensis.api_key
    end
    
    it "should return results" do
      res = Sensis.search(:key => @api_key, :query => "poker", :location => "2034")
      res.results.size.should == 20
      res.code.should == 200
    end
    
    it "should raise error if :key is missing" do
      lambda { Sensis.search }.should raise_error(RuntimeError) 
    end
    
    it "should raise error if both query and location are missing" do
      lambda { Sensis.search(:key => "asdf") }.should raise_error(RuntimeError) 
    end
    
    it "should raise Net::HTTPServerException when an invalid key is given" do
      lambda {
        res = Sensis.search(:key => "43nb7zf444", :query => "poker", :location => "2034") 
      }.should raise_error(Net::HTTPServerException)
    end
    
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sensis-0.0.3 spec/lib/search_spec.rb