Improving testing and coverage.
authorBob Aman <bobaman@google.com>
Thu, 30 Sep 2010 21:46:08 +0000 (21:46 +0000)
committerBob Aman <bobaman@google.com>
Thu, 30 Sep 2010 21:46:08 +0000 (21:46 +0000)
git-svn-id: https://google-api-ruby-client.googlecode.com/svn/trunk@38 c1d61fac-ed7f-fcc1-18f7-ff78120a04ef

spec/google/api_client/discovery_spec.rb

index 0edf4806952093df1797d8b90ae081f7f6d64925..fc1894ec450023306aea0277c59b9b76bda7c468 100644 (file)
@@ -302,3 +302,57 @@ describe Google::APIClient, 'configured for the buzz API' do
     status.should == 200
   end
 end
+
+describe Google::APIClient, 'configured for the latitude API' do
+  before do
+    @client = Google::APIClient.new(:service => 'latitude')
+  end
+
+  it 'should correctly determine the discovery URI' do
+    @client.discovery_uri.should ===
+      'http://www.googleapis.com/discovery/0.1/describe?api=latitude'
+  end
+
+  it 'should find APIs that are in the discovery document' do
+    @client.discovered_service('latitude').name.should == 'latitude'
+    @client.discovered_service('latitude').version.should == 'v1'
+  end
+
+  it 'should not find APIs that are not in the discovery document' do
+    @client.discovered_service('bogus').should == nil
+  end
+
+  it 'should find methods that are in the discovery document' do
+    @client.discovered_method('latitude.currentLocation.get').name.should ==
+      'get'
+  end
+
+  it 'should not find methods that are not in the discovery document' do
+    @client.discovered_method('latitude.bogus').should == nil
+  end
+
+  it 'should generate requests against the correct URIs' do
+    request = @client.generate_request(
+      'latitude.currentLocation.get',
+      {},
+      '',
+      [],
+      {:signed => false}
+    )
+    method, uri, headers, body = request
+    uri.should ==
+      'https://www.googleapis.com/latitude/v1/currentLocation'
+  end
+
+  it 'should not be able to execute requests without authorization' do
+    response = @client.execute(
+      'latitude.currentLocation.get',
+      {},
+      '',
+      [],
+      {:signed => false}
+    )
+    status, headers, body = response
+    status.should == 401
+  end
+end