test/test_mxhero_api.rb in mxhero-api-0.1.2 vs test/test_mxhero_api.rb in mxhero-api-0.1.3

- old
+ new

@@ -1,6 +1,6 @@ - require_relative 'helper' +require_relative 'helper' class MxHeroAPITest < MiniTest::Unit::TestCase def setup @api = MxHero::API::Client.new(username: TEST_API_USER, password: TEST_API_PASSWORD, verbose: false, api_url: TEST_API_URL) @@ -66,9 +66,27 @@ end end def test_domain_by_id_param_could_not_be_nil assert_raises(RuntimeError) { @api.domain_by_id } + end + + def test_accounts_by_domain + VCR.use_cassette('accounts_from_domain') do + domain = 'mxhero.com' + response = @api.accounts_by_domain(domain) + must_have_the_keys(response, %w( elements totalElements totalPages actualPage )) + response[:elements].each do |account| + must_have_the_keys(account, %w( account domain createdDate updatedDate group aliases dataSource ) ) + account[:aliases].each { |t_alias| must_have_the_keys(t_alias, %w( name domain dataSource )) } + end + end + end + + def must_have_the_keys(hash, keys) + keys.each do |key| + assert hash.key?(key.to_sym), "must have the key #{key}" + end end def rule_msg_with_domain(domain) msg = create_rule_msg msg[:domain] = domain