From 5983fe3416cc2d0ccbfb52203495a2fe65e7ad09 Mon Sep 17 00:00:00 2001 From: Nikolaj Nikolajsen Date: Wed, 8 Aug 2012 13:59:19 +0200 Subject: [PATCH] Cleaning up the tests supporting moped a little --- Gemfile.lock | 2 +- spec/ext/mongoid_spec.rb | 17 ++++------------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e097959..8acbb80 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - awesome_print (1.0.0) + awesome_print (1.0.2) GEM remote: http://rubygems.org/ diff --git a/spec/ext/mongoid_spec.rb b/spec/ext/mongoid_spec.rb index 148496f..bb4c882 100644 --- a/spec/ext/mongoid_spec.rb +++ b/spec/ext/mongoid_spec.rb @@ -22,23 +22,14 @@ begin user = MongoUser.new :first_name => "Al", :last_name => "Capone" out = @ap.send :awesome, user - if defined?(::Moped) - str = <<-EOS.strip + object_id = defined?(::Moped) ? '"424242424242424242424242"' : "BSON::ObjectId('424242424242424242424242')" + str = <<-EOS.strip # { - :_id => "424242424242424242424242", + :_id => #{object_id}, :first_name => "Al", :last_name => "Capone" } EOS - else - str = <<-EOS.strip -# { - :_id => BSON::ObjectId('424242424242424242424242'), - :first_name => "Al", - :last_name => "Capone" -} -EOS - end out.gsub!(/0x([a-f\d]+)/, "0x01234567") if defined?(::Moped) out.gsub!(/:_id => \"[^"]+/, ":_id => \"424242424242424242424242") @@ -67,7 +58,7 @@ EOS end moped_or_not = defined?(::Moped) ? 'moped/' : '' - last_attribute = defined?(::BSON) ? '"mongoid/fields/serializable/object"' : 'object' + last_attribute = defined?(::Moped) ? 'object' : '"mongoid/fields/serializable/object"' @ap.send(:awesome, Chamelion).should == <<-EOS.strip class Chamelion < Object { :_id => :"#{moped_or_not}bson/object_id",