Skip to content

Commit b12533a

Browse files
committed
add spec for OptionDefinition with block with arity 2
1 parent d0dd011 commit b12533a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

spec/image_optim/option_definition_spec.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,30 @@
9292
end
9393
end
9494
end
95+
96+
context 'when proc with arity 2 given' do
97+
subject do
98+
described_class.new('abc', :def, 'desc'){ |a, b| [a.inspect, b] }
99+
end
100+
101+
context 'when option not provided' do
102+
it 'returns default passed through proc' do
103+
expect(subject.value(nil, {})).to eq([':def', subject])
104+
end
105+
end
106+
107+
context 'when option is nil' do
108+
it 'returns nil passed through proc' do
109+
expect(subject.value(nil, :abc => nil)).to eq(['nil', subject])
110+
end
111+
end
112+
113+
context 'when option is set' do
114+
it 'returns value passed through proc' do
115+
expect(subject.value(nil, :abc => 123)).to eq(['123', subject])
116+
end
117+
end
118+
end
95119
end
96120

97121
describe '#default_description' do

0 commit comments

Comments
 (0)