diff --git a/spec/services/chef_spec.rb b/spec/services/chef_spec.rb index 4d2c7d3..1bbd735 100644 --- a/spec/services/chef_spec.rb +++ b/spec/services/chef_spec.rb @@ -48,15 +48,17 @@ describe 'Registered in consul' do serv_consul = 'erchef' api_endpoint = 'http://localhost:8500/v1' - service_json_cluster = command("curl -s #{api_endpoint}/catalog/service/#{serv_consul} | jq -c 'group_by(.ID)[]'").stdout.chomp.split("\n") - health_cluster = command("curl -s #{api_endpoint}/health/service/#{serv_consul} | jq -r '.[].Checks[0].Status'").stdout.chomp.split("\n") + service_json_cluster = command("curl -s #{api_endpoint}/catalog/service/#{serv_consul} | jq -c 'group_by(.ID)[]'") + service_json_cluster = service_json_cluster.stdout.chomp.split("\n") + health_cluster = command("curl -s #{api_endpoint}/health/service/#{serv_consul} | jq -r '.[].Checks[0].Status'") + health_cluster = health_cluster.stdout.chomp.split("\n") service_and_health = service_json_cluster.zip(health_cluster) service_and_health.each do |service, health| registered = JSON.parse(service)[0].key?('Address') && health == 'passing' # ? true : false it 'Should be registered and enabled' do expect(registered).to be true end - end + end end end end