diff --git a/spec/courier_spec.rb b/spec/courier_spec.rb index 17291f79..12ebace5 100644 --- a/spec/courier_spec.rb +++ b/spec/courier_spec.rb @@ -622,7 +622,8 @@ "log level": "debug", "log syslog": false, "log stdout": false, - "log file": "#{TEMP_PATH}/logs/log.log" + "log file": "#{TEMP_PATH}/logs/log.log", + "host": "custom.hostname.local" }, "network": { "ssl ca": "#{@ssl_cert.path}", @@ -641,7 +642,7 @@ f.log 5000 # Receive and check - receive_and_check + receive_and_check host: 'custom.hostname.local' shutdown expect(File.file?("#{TEMP_PATH}/logs/log.log")).to be true diff --git a/spec/lib/helpers/common.rb b/spec/lib/helpers/common.rb index eab265ca..bf93570d 100644 --- a/spec/lib/helpers/common.rb +++ b/spec/lib/helpers/common.rb @@ -158,7 +158,8 @@ def receive_and_check(args = {}, &block) total: nil, check: true, check_file: true, - check_order: true + check_order: true, + host: nil }.merge!(args) # Quick check of the total events we are expecting - but allow time to receive them @@ -170,6 +171,10 @@ def receive_and_check(args = {}, &block) total = args[:total] end + args.delete_if do |k,v| + v.nil? + end + orig_total = total check = args[:check] @@ -189,7 +194,7 @@ def receive_and_check(args = {}, &block) if block.nil? found = @files.find do |f| next unless f.pending? - f.logged?(check_file: args[:check_file], check_order: args[:check_order], event: e) + f.logged?(event: e, **args) end expect(found).to_not be_nil, "Event received not recognised: #{e}" else diff --git a/spec/lib/logfile.rb b/spec/lib/logfile.rb index ba3a08e4..a2e93b97 100644 --- a/spec/lib/logfile.rb +++ b/spec/lib/logfile.rb @@ -79,14 +79,15 @@ def pending? def logged?(args = {}) args = { - event: { 'host' => nil }, - check_file: true, - check_order: true + event: { 'host' => nil }, + check_file: true, + check_order: true, + host: @host }.merge!(args) event = args[:event] - return false if event['host'] != @host + return false if event['host'] != args[:host] return false if args[:check_file] && event['path'] != @orig_path if args[:check_order]