Permalink
Browse files

RUBY-277 remove dependencies on mongo gem from BSON tests.

  • Loading branch information...
1 parent 82b1037 commit 0ce614a55e75ebdfb49fb2f3c4406d19517be030 @banker banker committed Aug 9, 2011
View
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
s.files = ['LICENSE.txt']
s.files += ['lib/bson.rb'] + Dir['lib/bson/**/*.rb']
s.files += ['bin/b2json', 'bin/j2bson']
- s.test_files = Dir['test/bson/*.rb']
+ s.test_files = Dir['test/bson/*.rb', 'test/support/hash_with_indifferent_access.rb']
s.executables = ['b2json', 'j2bson']
@@ -1,5 +1,5 @@
# encoding:utf-8
-require './test/test_helper'
+require './test/bson/test_helper'
class BinaryTest < Test::Unit::TestCase
context "Inspecting" do
@@ -1,5 +1,6 @@
# encoding:utf-8
-require './test/test_helper'
+require './test/bson/test_helper'
+require 'set'
if RUBY_VERSION < '1.9'
require 'complex'
@@ -1,5 +1,5 @@
# encoding: binary
-require './test/test_helper'
+require './test/bson/test_helper'
class ByteBufferTest < Test::Unit::TestCase
include BSON
@@ -1,5 +1,5 @@
# encoding:utf-8
-require './test/test_helper'
+require './test/bson/test_helper'
require './test/support/hash_with_indifferent_access'
class HashWithIndifferentAccessTest < Test::Unit::TestCase
@@ -1,4 +1,4 @@
-require './test/test_helper'
+require './test/bson/test_helper'
require 'rubygems'
require 'json'
@@ -1,10 +1,9 @@
-require './test/test_helper'
+require './test/bson/test_helper'
require 'rubygems'
require 'json'
class ObjectIdTest < Test::Unit::TestCase
- include Mongo
include BSON
def setup
@@ -65,18 +64,6 @@ def test_inspect
assert_equal "BSON::ObjectId('#{@o.to_s}')", @o.inspect
end
- def test_save_and_restore
- db = standard_connection.db(MONGO_TEST_DB)
- coll = db.collection('test')
-
- coll.remove
- coll << {'a' => 1, '_id' => @o}
-
- row = coll.find().collect.first
- assert_equal 1, row['a']
- assert_equal @o, row['_id']
- end
-
def test_from_string
hex_str = @o.to_s
o2 = ObjectId.from_string(hex_str)
@@ -1,4 +1,4 @@
-require './test/test_helper'
+require './test/bson/test_helper'
class OrderedHashTest < Test::Unit::TestCase
@@ -0,0 +1,46 @@
+require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'bson')
+require 'rubygems' if RUBY_VERSION < '1.9.0' && ENV['C_EXT']
+require 'test/unit'
+
+def silently
+ warn_level = $VERBOSE
+ $VERBOSE = nil
+ result = yield
+ $VERBOSE = warn_level
+ result
+end
+
+begin
+ require 'rubygems' if RUBY_VERSION < "1.9.0" && !ENV['C_EXT']
+ silently { require 'shoulda' }
+ silently { require 'mocha' }
+rescue LoadError
+ puts <<MSG
+
+This test suite requires shoulda and mocha.
+You can install them as follows:
+ gem install shoulda
+ gem install mocha
+
+MSG
+
+ exit
+end
+
+require 'bson_ext/cbson' if !(RUBY_PLATFORM =~ /java/) && ENV['C_EXT']
+
+class Test::Unit::TestCase
+ include BSON
+
+ def assert_raise_error(klass, message)
+ begin
+ yield
+ rescue => e
+ assert_equal klass, e.class
+ assert e.message.include?(message), "#{e.message} does not include #{message}."
+ else
+ flunk "Expected assertion #{klass} but none was raised."
+ end
+ end
+
+end
@@ -1,7 +1,6 @@
-require './test/test_helper'
+require './test/bson/test_helper'
class TimestampTest < Test::Unit::TestCase
- include Mongo
def test_timestamp_equality
t1 = Timestamp.new(5000, 200)

0 comments on commit 0ce614a

Please sign in to comment.