spec/mongoid/token/collisions_spec.rb in mongoid_token-2.0.1 vs spec/mongoid/token/collisions_spec.rb in mongoid_token-2.0.2
- old
+ new
@@ -1,7 +1,9 @@
require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])
+require 'pp'
+
describe Mongoid::Token::Collisions do
let(:document) { Object.new }
describe "#resolve_token_collisions" do
context "when there is a duplicate token" do
let(:resolver) { double("Mongoid::Token::CollisionResolver") }
@@ -35,9 +37,18 @@
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(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"})
+ expect{document.resolve_token_collisions(resolver) { raise e }}.to raise_error(e)
end
end
end
end