#-- # gravaty # Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Marco Bresciani # # This file is part of gravaty. # # gravaty is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # gravaty is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License # along with gravaty. If not, see . #++ require_relative '../../test_helper' describe Gravaty::Utils::RpcConnector do before do I18n.load_path = Dir[File.join(File.dirname(__FILE__), '/../../../lib/gravaty/locales/', '*.yml')] I18n.locale = 'it' end digest = Digest::MD5.hexdigest('[YOUR EMAIL HERE]'.downcase) password = '[YOUR PASSWORD HERE]' subject {Gravaty::Utils::RpcConnector::RpcConnector .new digest, password} describe 'when receiving an invalid parameter' do [nil, ''].each do |param| it "shall raise an ArgumentError when digest is '#{param}'" do assert_raises ArgumentError do Gravaty::Utils::RpcConnector::RpcConnector.new param, password end end it "shall raise an ArgumentError when password is '#{param}'" do assert_raises ArgumentError do Gravaty::Utils::RpcConnector::RpcConnector.new digest, param end end it "shall raise an ArgumentError when parameters are '#{param}'" do assert_raises ArgumentError do Gravaty::Utils::RpcConnector::RpcConnector.new param, param end end end end describe 'when created with valid parameters' do it 'shall provide an useable connector' do subject.wont_be_nil end it 'shall provide information through test method' do skip 'This test shall be configured with own Gravatar email and password.' result = subject.call(Gravaty::RPC_TEST_METHOD) result.wont_be_nil result.wont_be_empty result['response'].wont_be_nil end it 'shall provide information through exists method' do skip 'This test shall be configured with own Gravatar email and password.' result = subject.call('grav.exists', hashes: [digest]) result.wont_be_nil result.wont_be_empty result[digest].wont_be_nil end end end