Sha256: 15ca446d5b10bdc60d02025c6dc1f7a18dc92fbb9c39b2ac7ed77f360d7502dd
Contents?: true
Size: 1.67 KB
Versions: 2
Compression:
Stored size: 1.67 KB
Contents
# frozen_string_literal: true require 'test_helper' class OptionsParsingTest < GemTestCase def parse_options(options) WithAdvisoryLock::Base.new(mock, mock, options) end test 'defaults (empty hash)' do impl = parse_options({}) assert_nil(impl.timeout_seconds) assert_not(impl.shared) assert_not(impl.transaction) end test 'nil sets timeout to nil' do impl = parse_options(nil) assert_nil(impl.timeout_seconds) assert_not(impl.shared) assert_not(impl.transaction) end test 'integer sets timeout to value' do impl = parse_options(42) assert_equal(42, impl.timeout_seconds) assert_not(impl.shared) assert_not(impl.transaction) end test 'hash with invalid key errors' do assert_raises(ArgumentError) do parse_options(foo: 42) end end test 'hash with timeout_seconds sets timeout to value' do impl = parse_options(timeout_seconds: 123) assert_equal(123, impl.timeout_seconds) assert_not(impl.shared) assert_not(impl.transaction) end test 'hash with shared option sets shared to true' do impl = parse_options(shared: true) assert_nil(impl.timeout_seconds) assert(impl.shared) assert_not(impl.transaction) end test 'hash with transaction option set transaction to true' do impl = parse_options(transaction: true) assert_nil(impl.timeout_seconds) assert_not(impl.shared) assert(impl.transaction) end test 'hash with multiple keys sets options' do foo = mock bar = mock impl = parse_options(timeout_seconds: foo, shared: bar) assert_equal(foo, impl.timeout_seconds) assert_equal(bar, impl.shared) assert_not(impl.transaction) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
with_advisory_lock-5.1.0 | test/options_test.rb |
with_advisory_lock-5.0.0 | test/options_test.rb |