Skip to content

Commit 4c1b51c

Browse files
authored
Merge pull request #756 from hunner/newline_integers
(maint) Stdlib::Compat::Integer accepts numbers with newlines apparently
2 parents 0001566 + c4d84d4 commit 4c1b51c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

spec/aliases/integer_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
'3',
99
-3,
1010
'-3',
11+
"123\nfoo",
12+
"foo\n123",
1113
].each do |value|
1214
describe value.inspect do
1315
let(:params) {{ value: value }}
@@ -17,7 +19,7 @@
1719
end
1820

1921
describe 'rejects other values' do
20-
[ true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', {}, { 'key' => 'value' }, { 1=> 2 }, '', :undef , 'x', 3.7, '3.7',-3.7, '-342.2315e-12' ].each do |value|
22+
[ "foo\nbar", true, 'true', false, 'false', 'iAmAString', '1test', '1 test', 'test 1', 'test 1 test', {}, { 'key' => 'value' }, { 1=> 2 }, '', :undef , 'x', 3.7, '3.7',-3.7, '-342.2315e-12' ].each do |value|
2123
describe value.inspect do
2224
let(:params) {{ value: value }}
2325
it { is_expected.to compile.and_raise_error(/parameter 'value' expects a value of type Integer, Pattern(\[.*\]+)?, or Array/) }

spec/functions/is_integer_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
it { is_expected.to run.with_params('3').and_return(true) }
1212
it { is_expected.to run.with_params(-3).and_return(true) }
1313
it { is_expected.to run.with_params('-3').and_return(true) }
14+
it { is_expected.to run.with_params("123\nfoo").and_return(true) }
15+
it { is_expected.to run.with_params("foo\n123").and_return(true) }
1416

1517
it { is_expected.to run.with_params(3.7).and_return(false) }
1618
it { is_expected.to run.with_params('3.7').and_return(false) }
@@ -24,6 +26,7 @@
2426
it { is_expected.to run.with_params(true).and_return(false) }
2527
it { is_expected.to run.with_params(false).and_return(false) }
2628
it { is_expected.to run.with_params('0001234').and_return(false) }
29+
it { is_expected.to run.with_params("foo\nbar").and_return(false) }
2730

2831
context 'Checking for deprecation warning' do
2932
after(:all) do

0 commit comments

Comments
 (0)