Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 0ce614a55e75ebdfb49fb2f3c4406d19517be030 1 parent 82b1037
Kyle Banker banker authored
2  bson.gemspec
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14 14 s.files = ['LICENSE.txt']
15 15 s.files += ['lib/bson.rb'] + Dir['lib/bson/**/*.rb']
16 16 s.files += ['bin/b2json', 'bin/j2bson']
17   - s.test_files = Dir['test/bson/*.rb']
  17 + s.test_files = Dir['test/bson/*.rb', 'test/support/hash_with_indifferent_access.rb']
18 18
19 19 s.executables = ['b2json', 'j2bson']
20 20
2  test/bson/binary_test.rb
... ... @@ -1,5 +1,5 @@
1 1 # encoding:utf-8
2   -require './test/test_helper'
  2 +require './test/bson/test_helper'
3 3
4 4 class BinaryTest < Test::Unit::TestCase
5 5 context "Inspecting" do
3  test/bson/bson_test.rb
... ... @@ -1,5 +1,6 @@
1 1 # encoding:utf-8
2   -require './test/test_helper'
  2 +require './test/bson/test_helper'
  3 +require 'set'
3 4
4 5 if RUBY_VERSION < '1.9'
5 6 require 'complex'
2  test/bson/byte_buffer_test.rb
... ... @@ -1,5 +1,5 @@
1 1 # encoding: binary
2   -require './test/test_helper'
  2 +require './test/bson/test_helper'
3 3
4 4 class ByteBufferTest < Test::Unit::TestCase
5 5 include BSON
2  test/bson/hash_with_indifferent_access_test.rb
... ... @@ -1,5 +1,5 @@
1 1 # encoding:utf-8
2   -require './test/test_helper'
  2 +require './test/bson/test_helper'
3 3 require './test/support/hash_with_indifferent_access'
4 4
5 5 class HashWithIndifferentAccessTest < Test::Unit::TestCase
2  test/bson/json_test.rb
... ... @@ -1,4 +1,4 @@
1   -require './test/test_helper'
  1 +require './test/bson/test_helper'
2 2 require 'rubygems'
3 3 require 'json'
4 4
15 test/bson/object_id_test.rb
... ... @@ -1,10 +1,9 @@
1   -require './test/test_helper'
  1 +require './test/bson/test_helper'
2 2 require 'rubygems'
3 3 require 'json'
4 4
5 5 class ObjectIdTest < Test::Unit::TestCase
6 6
7   - include Mongo
8 7 include BSON
9 8
10 9 def setup
@@ -65,18 +64,6 @@ def test_inspect
65 64 assert_equal "BSON::ObjectId('#{@o.to_s}')", @o.inspect
66 65 end
67 66
68   - def test_save_and_restore
69   - db = standard_connection.db(MONGO_TEST_DB)
70   - coll = db.collection('test')
71   -
72   - coll.remove
73   - coll << {'a' => 1, '_id' => @o}
74   -
75   - row = coll.find().collect.first
76   - assert_equal 1, row['a']
77   - assert_equal @o, row['_id']
78   - end
79   -
80 67 def test_from_string
81 68 hex_str = @o.to_s
82 69 o2 = ObjectId.from_string(hex_str)
2  test/bson/ordered_hash_test.rb
... ... @@ -1,4 +1,4 @@
1   -require './test/test_helper'
  1 +require './test/bson/test_helper'
2 2
3 3 class OrderedHashTest < Test::Unit::TestCase
4 4
46 test/bson/test_helper.rb
... ... @@ -0,0 +1,46 @@
  1 +require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'bson')
  2 +require 'rubygems' if RUBY_VERSION < '1.9.0' && ENV['C_EXT']
  3 +require 'test/unit'
  4 +
  5 +def silently
  6 + warn_level = $VERBOSE
  7 + $VERBOSE = nil
  8 + result = yield
  9 + $VERBOSE = warn_level
  10 + result
  11 +end
  12 +
  13 +begin
  14 + require 'rubygems' if RUBY_VERSION < "1.9.0" && !ENV['C_EXT']
  15 + silently { require 'shoulda' }
  16 + silently { require 'mocha' }
  17 +rescue LoadError
  18 + puts <<MSG
  19 +
  20 +This test suite requires shoulda and mocha.
  21 +You can install them as follows:
  22 + gem install shoulda
  23 + gem install mocha
  24 +
  25 +MSG
  26 +
  27 + exit
  28 +end
  29 +
  30 +require 'bson_ext/cbson' if !(RUBY_PLATFORM =~ /java/) && ENV['C_EXT']
  31 +
  32 +class Test::Unit::TestCase
  33 + include BSON
  34 +
  35 + def assert_raise_error(klass, message)
  36 + begin
  37 + yield
  38 + rescue => e
  39 + assert_equal klass, e.class
  40 + assert e.message.include?(message), "#{e.message} does not include #{message}."
  41 + else
  42 + flunk "Expected assertion #{klass} but none was raised."
  43 + end
  44 + end
  45 +
  46 +end
3  test/bson/timestamp_test.rb
... ... @@ -1,7 +1,6 @@
1   -require './test/test_helper'
  1 +require './test/bson/test_helper'
2 2
3 3 class TimestampTest < Test::Unit::TestCase
4   - include Mongo
5 4
6 5 def test_timestamp_equality
7 6 t1 = Timestamp.new(5000, 200)

0 comments on commit 0ce614a

Vít Ondruch

In my original patch, I removed also this include and the test suite worked. Is this include really necessary?

Kyle Banker

Just removed. Thanks.

Please sign in to comment.
Something went wrong with that request. Please try again.