spec/mongoid/token/finders_spec.rb in mongoid_token-2.0.2 vs spec/mongoid/token/finders_spec.rb in mongoid_token-2.1.0

- old
+ new

@@ -10,20 +10,20 @@ Mongoid::Token::Finders.define_custom_token_finder_for(klass, field) klass.singleton_methods.should include(:"find_by_#{field}") end it "override the `find` method of the document" do - klass = Class.new + klass = Class.new klass.define_singleton_method(:find) {|*args| :original_find } klass.define_singleton_method(:find_by) {|*args| :token_find } Mongoid::Token::Finders.define_custom_token_finder_for(klass) - klass.find(Moped::BSON::ObjectId.new).should == :original_find - klass.find(Moped::BSON::ObjectId.new, Moped::BSON::ObjectId.new).should == :original_find + klass.find(BSON::ObjectId.new).should == :original_find + klass.find(BSON::ObjectId.new, BSON::ObjectId.new).should == :original_find klass.find().should == :original_find - klass.find(Moped::BSON::ObjectId.new, "token").should == :token_find + klass.find(BSON::ObjectId.new, "token").should == :token_find klass.find("token").should == :token_find end it "retrieve a document using the dynamic finder" do class Document; include Mongoid::Document; field :token; end @@ -31,11 +31,11 @@ Mongoid::Token::Finders.define_custom_token_finder_for(Document) Document.find_by_token("1234").should == document end it "retrieve a document using the `find` method" do - class Document; include Mongoid::Document; field :token; end - document = Document.create! :token => "1234" - Mongoid::Token::Finders.define_custom_token_finder_for(Document) - Document.find("1234").should == document + class AnotherDocument; include Mongoid::Document; field :token; end + document = AnotherDocument.create! :token => "1234" + Mongoid::Token::Finders.define_custom_token_finder_for(AnotherDocument) + AnotherDocument.find("1234").should == document end end