Skip to content

Commit

Permalink
ConstraintError -> ConstraintViolationError to be closer to Cypher re…
Browse files Browse the repository at this point in the history
…sponse
  • Loading branch information
subvertallchris committed Jul 17, 2015
1 parent 4e6be72 commit 4047092
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/neo4j-server/cypher_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def initialize(msg, status, code)
end
end

class ConstraintError < ResponseError; end
class ConstraintViolationError < ResponseError; end

class HashEnumeration
include Enumerable
Expand Down Expand Up @@ -205,7 +205,7 @@ def set_error(error)
CONSTRAINT_ERROR = 'Neo.ClientError.Schema.ConstraintViolation'
def raise_error
fail 'Tried to raise error without an error' unless @error
error_class = constraint_error? ? ConstraintError : ResponseError
error_class = constraint_error? ? ConstraintViolationError : ResponseError
fail error_class.new(@error_msg, @error_status, @error_code)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/neo4j-server/unit/cypher_response_unit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ def successful_response(response)
end
end

describe 'CypherResponse::ConstraintError' do
describe 'CypherResponse::ConstraintViolationError' do
it 'inherits from ResponseError' do
expect(CypherResponse::ConstraintError.new(nil, nil, nil)).to be_a(CypherResponse::ResponseError)
expect(CypherResponse::ConstraintViolationError.new(nil, nil, nil)).to be_a(CypherResponse::ResponseError)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/shared_examples/label.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@
Neo4j::Session.current.query.match('(n:MyFoo)').delete(:n).exec
end

it 'raises a ConstraintError' do
it 'raises a ConstraintViolationError' do
expect { Neo4j::Node.create({bar: 'dawn'}, :MyFoo) }.not_to raise_error
expect { Neo4j::Node.create({bar: 'dawn'}, :MyFoo) }.to raise_error { Neo4j::Server::CypherResponse::ConstraintError }
expect { Neo4j::Node.create({bar: 'dawn'}, :MyFoo) }.to raise_error { Neo4j::Server::CypherResponse::ConstraintViolationError }
end
end

Expand Down

0 comments on commit 4047092

Please sign in to comment.