Sha256: b0cd8a08e0a6fe9f3847ecc4207e63f6b0027189a85de3d0b8591930d3704919
Contents?: true
Size: 1.29 KB
Versions: 3
Compression:
Stored size: 1.29 KB
Contents
# frozen_string_literal: true describe 'Settings as Predicates' do specify 'boolean nature of the option value' do class BooleanCheckConfig < Qonfig::DataSet setting :database do setting :user setting :host, 'google.com' end setting :enable_mocks, true end config = BooleanCheckConfig.new # predicats expect(config.settings.database.user?).to eq(false) expect(config.settings.database.host?).to eq(true) expect(config.settings.enable_mocks?).to eq(true) # setting roots always returns true expect(config.settings.database?).to eq(true) # reconfigure and check again config.configure do |conf| conf.database.user = 'D@iVeR' conf.database.host = nil conf.enable_mocks = false end # predicates expect(config.settings.database.user?).to eq(true) expect(config.settings.database.host?).to eq(false) expect(config.settings.enable_mocks?).to eq(false) # setting roots always returns true expect(config.settings.database?).to eq(true) # clear all options config.configure do |conf| conf.database.user = nil conf.database.host = nil conf.enable_mocks = nil end # setting roots always returns true expect(config.settings.database?).to eq(true) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
qonfig-0.28.0 | spec/features/settings_as_predicates_spec.rb |
qonfig-0.27.0 | spec/features/settings_as_predicates_spec.rb |
qonfig-0.26.0 | spec/features/settings_as_predicates_spec.rb |