spec/mongoid/token/collisions_spec.rb in mongoid_token-3.0.0 vs spec/mongoid/token/collisions_spec.rb in mongoid_token-4.0.0
- old
+ new
@@ -15,38 +15,38 @@
context "and there are zero retries" do
it "should raise an error after the first try" do
resolver.stub(:retry_count).and_return(0)
attempts = 0
- expect{document.resolve_token_collisions(resolver) { attempts += 1; raise Moped::Errors::OperationFailure.new("","") }}.to raise_error Mongoid::Token::CollisionRetriesExceeded
+ expect{document.resolve_token_collisions(resolver) { attempts += 1; raise Mongo::Error::OperationFailure }}.to raise_error Mongoid::Token::CollisionRetriesExceeded
expect(attempts).to eq 1
end
end
context "and retries is set to 1" do
it "should raise an error after retrying once" do
resolver.stub(:retry_count).and_return(1)
attempts = 0
- expect{document.resolve_token_collisions(resolver) { attempts += 1; raise Moped::Errors::OperationFailure.new("","") }}.to raise_error Mongoid::Token::CollisionRetriesExceeded
+ expect{document.resolve_token_collisions(resolver) { attempts += 1; raise Mongo::Error::OperationFailure }}.to raise_error Mongoid::Token::CollisionRetriesExceeded
expect(attempts).to eq 2
end
end
context "and retries is greater than 1" do
it "should raise an error after retrying" do
resolver.stub(:retry_count).and_return(3)
attempts = 0
- expect{document.resolve_token_collisions(resolver) { attempts += 1; raise Moped::Errors::OperationFailure.new("","") }}.to raise_error Mongoid::Token::CollisionRetriesExceeded
+ expect{document.resolve_token_collisions(resolver) { attempts += 1; raise Mongo::Error::OperationFailure }}.to raise_error Mongoid::Token::CollisionRetriesExceeded
expect(attempts).to eq 4
end
end
context "and a different index is violated" do
it "should bubble the operation failure" do
document.stub(:is_duplicate_token_error?).and_return(false)
resolver.stub(:retry_count).and_return(3)
- e = Moped::Errors::OperationFailure.new("command", {:details => "nope"})
+ e = Mongo::Error::OperationFailure.new("nope")
expect{document.resolve_token_collisions(resolver) { raise e }}.to raise_error(e)
end
end
end
end
@@ -82,10 +82,10 @@
document.class.send(:include, Mongoid::Token::Collisions)
end
context "when there is a duplicate key error" do
it "should return true" do
document.stub("token").and_return("tokenvalue123")
- err = double("Moped::Errors::OperationFailure")
+ err = double("Mongo::Error::OperationFailure")
err.stub("details").and_return do
{
"err" => "E11000 duplicate key error index: mongoid_token_test.links.$token_1 dup key: { : \"tokenvalue123\" }",
"code" => 11000,
"n" => 0,