RUBY-222 BSON::Code must be a string.
This commit is contained in:
parent
65f59ba2d6
commit
bcb37e62c7
|
@ -32,6 +32,10 @@ module BSON
|
|||
def initialize(code, scope={})
|
||||
@code = code
|
||||
@scope = scope
|
||||
|
||||
unless @code.is_a?(String)
|
||||
raise ArgumentError, "BSON::Code must be in the form of a String; #{@code.class} is not allowed."
|
||||
end
|
||||
end
|
||||
|
||||
def length
|
||||
|
|
|
@ -150,6 +150,12 @@ class BSONTest < Test::Unit::TestCase
|
|||
assert_doc_pass(doc)
|
||||
end
|
||||
|
||||
def test_code_with_symbol
|
||||
assert_raise_error ArgumentError, "BSON::Code must be in the form of a String" do
|
||||
Code.new(:fubar)
|
||||
end
|
||||
end
|
||||
|
||||
def test_code_with_scope
|
||||
doc = {'$where' => Code.new('this.a.b < this.b', {'foo' => 1})}
|
||||
assert_doc_pass(doc)
|
||||
|
|
Loading…
Reference in New Issue