3 describe 'sprintf_hash' do
5 is_expected.not_to eq(nil)
8 context 'with param count' do
9 it 'fails with no arguments' do
10 is_expected.to run.with_params.and_raise_error(ArgumentError, %r{expects 2 arguments}i)
12 it 'fails with 1 argument' do
13 is_expected.to run.with_params('').and_raise_error(ArgumentError, %r{expects 2 arguments}i)
15 it 'fails with too many arguments' do
16 is_expected.to run.with_params('', '', '').and_raise_error(ArgumentError, %r{expects 2 arguments}i)
20 context 'with param type' do
21 it 'fails with wrong format type' do
22 is_expected.to run.with_params(false, {}).and_raise_error(ArgumentError, %r{parameter 'format' expects a String value}i)
24 it 'fails with wrong arguments type' do
25 is_expected.to run.with_params('', false).and_raise_error(ArgumentError, %r{parameter 'arguments' expects a Hash value}i)
29 it 'prints formats with name placeholders' do
30 is_expected.to run.with_params('string %<foo>s and integer %<bar>b', 'foo' => '_foo_', 'bar' => 5) # rubocop:disable Style/FormatStringToken : Template tokens needed for purposes of test
31 .and_return('string _foo_ and integer 101')