Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rescue from correct Faraday error #164

Merged
merged 1 commit into from
Jun 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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