Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
BSON id parsing
require 'spec_helper'
def parse_id(id)
BSON::ObjectId(id)
rescue BSON::InvalidObjectId
nil
end
describe BSON do
describe 'when the id is a valid BSON id' do
it 'returns it' do
parse_id("SOME VALID BSON ID").must_be_kind_of BSON::ObjectId
end
end
describe 'otherwise' do
it 'returns nil' do
parse_id("aiejfioaej").must_be_nil
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.