Skip to content

Commit

Permalink
Merge pull request #164 from ekampp/patch-1
Browse files Browse the repository at this point in the history
Rescue from correct Faraday error
  • Loading branch information
Andy Fleener committed Jun 5, 2020
2 parents 2ba2088 + 7f9c098 commit f8f7f52
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/ok_computer/built_in_checks/neo4j_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def check
connected = Neo4j::Session.current.connection.head.success?
url = Neo4j::Session.current.connection.url_prefix.to_s
mark_message "Connected to neo4j on #{url}" if connected
rescue Faraday::Error::ConnectionFailed => e
rescue Faraday::ConnectionFailed => e
mark_failure
mark_message "Error: #{e.message}"
end
Expand Down
8 changes: 3 additions & 5 deletions spec/ok_computer/built_in_checks/neo4j_check_spec.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
require "rails_helper"

# Stubbing the constant out; will exist in apps which have Neo4j loaded
# Stubbing the constants out; will exist in apps which have Neo4j loaded
module Neo4j
class Session
end
end

module Faraday
module Error
class ConnectionFailed < StandardError; end
end
class ConnectionFailed < StandardError; end
end

module OkComputer
Expand All @@ -32,7 +30,7 @@ module OkComputer

context "with an unsuccessful connection" do
let(:error_message) { "connection refused: localhost:7474" }
let(:error) { Faraday::Error::ConnectionFailed.new(error_message) }
let(:error) { Faraday::ConnectionFailed.new(error_message) }

before do
allow(Neo4j::Session).to receive_message_chain("current.connection.head.success?").and_raise(error)
Expand Down

0 comments on commit f8f7f52

Please sign in to comment.