From 6f69e8572525f775f360ee1afd2e94bbd6ec2e28 Mon Sep 17 00:00:00 2001 From: Zadat Olayinka Date: Wed, 30 Jun 2021 09:55:03 +0100 Subject: [PATCH] refactor instance of test --- ruby-sdk/fyipe/spec/fyipe_logger_spec.rb | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/ruby-sdk/fyipe/spec/fyipe_logger_spec.rb b/ruby-sdk/fyipe/spec/fyipe_logger_spec.rb index 0c609fd9a6..f2f05f68c4 100644 --- a/ruby-sdk/fyipe/spec/fyipe_logger_spec.rb +++ b/ruby-sdk/fyipe/spec/fyipe_logger_spec.rb @@ -55,7 +55,7 @@ RSpec.describe FyipeLogger do logger = FyipeLogger.new($apiUrl, $applicationLog["_id"], $applicationLog["key"]) response = logger.log(log) expect(response['content']).to eql log - expect(response['content'].class.to_s).to eql "String" + expect(response['content']).to be_an_instance_of(String) expect(response['type']).to eql "info" end it 'test_valid_object_content_of_type_info_is_logged' do @@ -66,7 +66,7 @@ RSpec.describe FyipeLogger do logger = FyipeLogger.new($apiUrl, $applicationLog["_id"], $applicationLog["key"]) response = logger.log(log) expect(response['content']["location"]).to eql log["location"] - expect(response['content'].class.to_s).to eql "Hash" + expect(response['content']).to be_an_instance_of(Hash) expect(response['type']).to eql "info" end it 'test_valid_string_content_of_type_error_is_logged' do @@ -74,7 +74,7 @@ RSpec.describe FyipeLogger do logger = FyipeLogger.new($apiUrl, $applicationLog["_id"], $applicationLog["key"]) response = logger.error(log) expect(response['content']).to eql log - expect(response['content'].class.to_s).to eql "String" + expect(response['content']).to be_an_instance_of(String) expect(response['type']).to eql "error" end it 'test_valid_object_content_of_type_warning_is_logged' do @@ -85,7 +85,7 @@ RSpec.describe FyipeLogger do logger = FyipeLogger.new($apiUrl, $applicationLog["_id"], $applicationLog["key"]) response = logger.warning(log) expect(response['content']["location"]).to eql log["location"] - expect(response['content'].class.to_s).to eql "Hash" + expect(response['content']).to be_an_instance_of(Hash) expect(response['type']).to eql "warning" end it 'test_valid_object_content_of_type_warning_with_one_tag_is_logged' do @@ -97,9 +97,9 @@ RSpec.describe FyipeLogger do logger = FyipeLogger.new($apiUrl, $applicationLog["_id"], $applicationLog["key"]) response = logger.warning(log, tag) expect(response['content']["location"]).to eql log["location"] - expect(response['content'].class.to_s).to eql "Hash" + expect(response['content']).to be_an_instance_of(Hash) expect(response['type']).to eql "warning" - expect(response['tags'].class.to_s).to eql "Array" + expect(response['tags']).to be_an_instance_of(Array) expect(response['tags'].find { |item| item == tag }).to_not be_nil end it 'test_valid_object_content_of_type_error_with_no_tag_is_logged' do @@ -107,10 +107,8 @@ RSpec.describe FyipeLogger do logger = FyipeLogger.new($apiUrl, $applicationLog["_id"], $applicationLog["key"]) response = logger.error(log) expect(response['content']).to eql log - expect(response['content'].class.to_s).to eql "String" + expect(response['content']).to be_an_instance_of(String) expect(response['type']).to eql "error" - expect(response['tags'].class.to_s).to eql "Array" - expect(response['tags']).to eql [] end it 'test_valid_object_content_of_type_warning_with_four_tags_is_logged' do log = { @@ -121,9 +119,9 @@ RSpec.describe FyipeLogger do logger = FyipeLogger.new($apiUrl, $applicationLog["_id"], $applicationLog["key"]) response = logger.warning(log, tags) expect(response['content']["location"]).to eql log["location"] - expect(response['content'].class.to_s).to eql "Hash" + expect(response['content']).to be_an_instance_of(Hash) expect(response['type']).to eql "warning" - expect(response['tags'].class.to_s).to eql "Array" + expect(response['tags']).to be_an_instance_of(Array) tags.each { |tag| expect(response['tags'].find { |item| item == tag }).to_not be_nil }