Skip to content

Commit

Permalink
Merge pull request #264 from samvera/fix_failing_tests
Browse files Browse the repository at this point in the history
allow error from RDF::Graph to be parsed with or without paren around code
  • Loading branch information
botimer authored Aug 8, 2019
2 parents 583c105 + dd60528 commit 96cf953
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 2 additions & 4 deletions app/services/qa/linked_data/graph_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,10 @@ def process_error(e, url)
end
end

# process ioerror_code from RDF::Graph.load whether the code is in parentheses (i.e. "... (404)"), or not (i.e. "... 404")
def ioerror_code(e)
msg = e.message
return 'format' if msg.start_with? "Unknown RDF format"
a = msg.size - 4
z = msg.size - 2
msg[a..z]
msg[/(\(?)(\d\d\d)(\)?)$/, 2]
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion spec/services/linked_data/graph_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
subject { described_class.load_graph(url: url) }

let(:url) { 'http://experimental.worldcat.org/fast/search?maximumRecords=3&query=cql.any%20all%20%22cornell%22&sortKeys=usage' }
let(:regurl) { 'http:\/\/experimental.worldcat.org\/fast\/search\?maximumRecords=3&query=cql.any%20all%20%22cornell%22&sortKeys=usage' }
let(:uri) { URI(url) }

before do
Expand All @@ -74,7 +75,7 @@
end

it 'raises error' do
expect { subject }.to raise_error(Qa::ServiceError, "Unknown error for #{uri.hostname} on port #{uri.port}. Try again later. (Cause - <#{url}>: (504))")
expect { subject }.to raise_error(Qa::ServiceError, /Unknown error for #{uri.hostname} on port #{uri.port}. Try again later. \(Cause - <#{regurl}>: \(?504\)?\)/)
end
end
end
Expand Down

0 comments on commit 96cf953

Please sign in to comment.