Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adds test coverage for the connection class.

git-svn-id: http://opensocial-ruby-client.googlecode.com/svn/trunk@16 f65e88d0-acf7-11dd-a0fe-71d3f493a0de
  • Loading branch information...
commit 78700174cef0c5a7a6bc3dad84f653fa77da373d 1 parent c1c71be
api.dwh@google.com authored
Showing with 50 additions and 0 deletions.
  1. +48 −0 tests/connection_test.rb
  2. +2 −0  tests/test.rb
View
48 tests/connection_test.rb
@@ -0,0 +1,48 @@
+# Copyright (c) 2008 Google Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require File.dirname(__FILE__) + '/test_helper.rb'
+
+class ConnectionTest < Test::Unit::TestCase #:nodoc:
+ include TestHelper
+
+ # Tests that a connection properly throws an exception invalid parameters are
+ # supplied
+ def test_invalid_connection_parameters
+ non_blank = 'foo'
+
+ pass_invalid_hmac_parameters(non_blank, '', '')
+ pass_invalid_hmac_parameters('', non_blank, '')
+ pass_invalid_hmac_parameters('', '', non_blank)
+
+ assert_raise ArgumentError do
+ c = OpenSocial::Connection.new(:auth => OpenSocial::Connection::AUTH_ST,
+ :st => '')
+ end
+
+ assert_raise ArgumentError do
+ c = OpenSocial::Connection.new(:auth => 1234124)
+ end
+ end
+
+ private
+
+ def pass_invalid_hmac_parameters(key, secret, id)
+ assert_raise ArgumentError do
+ c = OpenSocial::Connection.new(:consumer_key => key,
+ :consumer_secret => secret,
+ :xoauth_requestor_id => id)
+ end
+ end
+end
View
2  tests/test.rb
@@ -22,6 +22,7 @@
require File.dirname(__FILE__) + '/appdata_test'
require File.dirname(__FILE__) + '/rpcrequest_test'
require File.dirname(__FILE__) + '/request_test'
+require File.dirname(__FILE__) + '/connection_test'
require File.dirname(__FILE__) + '/online_test'
class TS_AllTests #:nodoc:
@@ -33,6 +34,7 @@ def self.suite
suite << PersonTest.suite
suite << RpcRequestTest.suite
suite << RequestTest.suite
+ suite << ConnectionTest.suite
suite << OnlineTest.suite
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.