1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
# frozen_string_literal: true
# rubocop:todo all
require "spec_helper"
describe Mongo::Config::Options do
let(:config) do
Mongo::Config
end
describe "#defaults" do
it "returns the default options" do
expect(config.defaults).to_not be_empty
end
end
describe "#option" do
context "when a default is provided" do
after do
config.reset
end
it "defines a getter" do
expect(config.validate_update_replace).to be false
end
it "defines a setter" do
expect(config.validate_update_replace = true).to be true
expect(config.validate_update_replace).to be true
end
it "defines a presence check" do
expect(config.validate_update_replace?).to be false
end
end
context 'when option is not a boolean' do
before do
config.validate_update_replace = 'foo'
end
after do
config.reset
end
context 'presence check' do
it 'is a boolean' do
expect(config.validate_update_replace?).to be true
end
end
end
end
describe "#reset" do
before do
config.validate_update_replace = true
config.reset
end
it "resets the settings to the defaults" do
expect(config.validate_update_replace).to be false
end
end
describe "#settings" do
it "returns the settings" do
expect(config.settings).to_not be_empty
end
end
end
|