Browse files

Fixed MongoMapper specs

  • Loading branch information...
1 parent e048d0f commit 8a0f6fa97e2b0f18c22030e76249b93fa32521b6 @michaeldv michaeldv committed May 6, 2011
Showing with 29 additions and 29 deletions.
  1. +29 −29 spec/mongo_mapper_spec.rb
View
58 spec/mongo_mapper_spec.rb
@@ -4,57 +4,57 @@
require "mongo_mapper"
require "ap/mixin/mongo_mapper"
- if defined?(::MongoMapper)
- class User
- include MongoMapper::Document
+ describe "AwesomePrint/MongoMapper" do
+ before :all do
+ class MongoUser
+ include MongoMapper::Document
- key :first_name, String
- key :last_name, String
+ key :first_name, String
+ key :last_name, String
+ end
end
- describe "AwesomePrint/MongoMapper" do
- before :each do
- @ap = AwesomePrint.new(:plain => true)
- end
+ before :each do
+ @ap = AwesomePrint.new(:plain => true)
+ end
- it "should print for a class instance" do
- user = User.new(:first_name => "Al", :last_name => "Capone")
- out = @ap.send(:awesome, user)
- str = <<-EOS.strip
-#<User:0x01234567> {
+ it "should print for a class instance" do
+ user = MongoUser.new(:first_name => "Al", :last_name => "Capone")
+ out = @ap.send(:awesome, user)
+ str = <<-EOS.strip
+#<MongoUser:0x01234567> {
"_id" => BSON::ObjectId('4d9183739a546f6806000001'),
"first_name" => "Al",
"last_name" => "Capone"
}
EOS
- out.gsub!(/'([\w]+){23}'/, "'4d9183739a546f6806000001'")
- out.gsub!(/0x([a-f\d]+)/, "0x01234567")
- out.should == str
- end
+ out.gsub!(/'([\w]+){23}'/, "'4d9183739a546f6806000001'")
+ out.gsub!(/0x([a-f\d]+)/, "0x01234567")
+ out.should == str
+ end
- it "should print for a class" do
- @ap.send(:awesome, User).should == <<-EOS.strip
-class User < Object {
+ it "should print for a class" do
+ @ap.send(:awesome, MongoUser).should == <<-EOS.strip
+class MongoUser < Object {
"_id" => :object_id,
"first_name" => :string,
"last_name" => :string
}
EOS
- end
+ end
- it "should print for a class when type is undefined" do
- class Chamelion
- include MongoMapper::Document
- key :last_attribute
- end
+ it "should print for a class when type is undefined" do
+ class Chamelion
+ include MongoMapper::Document
+ key :last_attribute
+ end
- @ap.send(:awesome, Chamelion).should == <<-EOS.strip
+ @ap.send(:awesome, Chamelion).should == <<-EOS.strip
class Chamelion < Object {
"_id" => :object_id,
"last_attribute" => :undefined
}
EOS
- end
end
end

0 comments on commit 8a0f6fa

Please sign in to comment.