Skip to content

Commit 4a07934

Browse files
comandeo-mongop
authored andcommitted
RUBY-2610 Add versioned API examples for docs (#2311)
* RUBY-2610 Add versioned API examples for docs * exercise and close the clients Co-authored-by: Oleg Pudeyev <[email protected]>
1 parent 477da27 commit 4a07934

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# frozen_string_literal: true
2+
# encoding: utf-8
3+
4+
require 'spec_helper'
5+
6+
describe 'Versioned API examples' do
7+
8+
# Until https://jira.mongodb.org/browse/RUBY-1768 is implemented, limit
9+
# the tests to simple configurations
10+
require_no_auth
11+
require_no_tls
12+
13+
let(:uri_string) do
14+
"mongodb://#{SpecConfig.instance.addresses.join(',')}"
15+
end
16+
17+
it 'Versioned API example 1' do
18+
19+
# Start Versioned API Example 1
20+
21+
client = Mongo::Client.new(uri_string, server_api: {version: "1"})
22+
23+
# End Versioned API Example 1
24+
25+
# Run a command to ensure the client works.
26+
client['test'].find.to_a.should be_a(Array)
27+
# Do not leak clients.
28+
client.close
29+
end
30+
31+
it 'Versioned API example 2' do
32+
# Start Versioned API Example 2
33+
34+
client = Mongo::Client.new(uri_string, server_api: {version: "1", strict: true})
35+
36+
# End Versioned API Example 2
37+
38+
# Run a command to ensure the client works.
39+
client['test'].find.to_a.should be_a(Array)
40+
# Do not leak clients.
41+
client.close
42+
end
43+
44+
it 'Versioned API example 3' do
45+
# Start Versioned API Example 3
46+
47+
client = Mongo::Client.new(uri_string, server_api: {version: "1", strict: false})
48+
49+
# End Versioned API Example 3
50+
51+
# Run a command to ensure the client works.
52+
client['test'].find.to_a.should be_a(Array)
53+
# Do not leak clients.
54+
client.close
55+
end
56+
57+
it 'Versioned API example 4' do
58+
# Start Versioned API Example 4
59+
60+
client = Mongo::Client.new(uri_string, server_api: {version: "1", deprecation_errors: true})
61+
62+
# End Versioned API Example 4
63+
64+
# Run a command to ensure the client works.
65+
client['test'].find.to_a.should be_a(Array)
66+
# Do not leak clients.
67+
client.close
68+
end
69+
end

0 commit comments

Comments
 (0)