test/client_test.rb in 3scale_client-2.4.2 vs test/client_test.rb in 3scale_client-2.5.0.pre1
- old
+ new
@@ -1,12 +1,13 @@
-require 'test/unit'
+require 'minitest/autorun'
+
require 'fakeweb'
require 'mocha/setup'
require '3scale/client'
-class ThreeScale::ClientTest < Test::Unit::TestCase
+class ThreeScale::ClientTest < MiniTest::Unit::TestCase
def client(options = {})
ThreeScale::Client.new({:provider_key => '1234abcd'}.merge(options))
end
@@ -17,11 +18,11 @@
@client = client
@host = ThreeScale::Client::DEFAULT_HOST
end
def test_raises_exception_if_provider_key_is_missing
- assert_raise ArgumentError do
+ assert_raises ArgumentError do
ThreeScale::Client.new({})
end
end
def test_default_host
@@ -204,11 +205,11 @@
end
def test_authorize_with_server_error
FakeWeb.register_uri(:get, "http://#{@host}/transactions/authorize.xml?provider_key=1234abcd&app_id=foo", :status => ['500', 'Internal Server Error'], :body => 'OMG! WTF!')
- assert_raise ThreeScale::ServerError do
+ assert_raises ThreeScale::ServerError do
@client.authorize(:app_id => 'foo')
end
end
def test_successful_oauth_authorize
@@ -309,17 +310,17 @@
end
def test_oauth_authorize_with_server_error
FakeWeb.register_uri(:get, "http://#{@host}/transactions/oauth_authorize.xml?provider_key=1234abcd&app_id=foo", :status => ['500', 'Internal Server Error'], :body => 'OMG! WTF!')
- assert_raise ThreeScale::ServerError do
+ assert_raises ThreeScale::ServerError do
@client.oauth_authorize(:app_id => 'foo')
end
end
def test_report_raises_an_exception_if_no_transactions_given
- assert_raise ArgumentError do
+ assert_raises ArgumentError do
@client.report
end
end
def test_successful_report
@@ -378,11 +379,11 @@
def test_report_with_server_error
FakeWeb.register_uri(:post, "http://#{@host}/transactions.xml",
:status => ['500', 'Internal Server Error'],
:body => 'OMG! WTF!')
- assert_raise ThreeScale::ServerError do
+ assert_raises ThreeScale::ServerError do
@client.report({:app_id => 'foo', :usage => {'hits' => 1}})
end
end
def test_authorize_client_header_sent
@@ -455,10 +456,18 @@
def assert_secure_authrep_url_with_params(str = '&%5Busage%5D%5Bhits%5D=1')
assert_authrep_url_with_params(str, 'https')
end
end
-class ThreeScale::PersistentClientTest < ThreeScale::ClientTest
+class ThreeScale::NetHttpPersistentClientTest < ThreeScale::ClientTest
def client(options = {})
+ ThreeScale::Client::HTTPClient.persistent_backend = ThreeScale::Client::HTTPClient::NetHttpPersistent
ThreeScale::Client.new({:provider_key => '1234abcd', :persistent => true}.merge(options))
end
-end
\ No newline at end of file
+end
+
+class ThreeScale::NetHttpKeepAliveClientTest < ThreeScale::NetHttpPersistentClientTest
+ def client(options = {})
+ ThreeScale::Client::HTTPClient.persistent_backend = ThreeScale::Client::HTTPClient::NetHttpKeepAlive
+ super
+ end
+end