File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,5 +3,6 @@ module Utils
33 def integral_string? ( value )
44 value . is_a? ( String ) && /^\d +$/ =~ value ? true : false
55 end
6+ module_function :integral_string?
67 end
78end
Original file line number Diff line number Diff line change @@ -30,14 +30,18 @@ def self.shutdown
3030 test '#pull_request?' do
3131 assert do
3232 EnvPullRequest . new do
33- ENV [ 'PULL_REQUEST_ID' ] . to_i if ENV [ 'PULL_REQUEST_ID' ]
33+ if Utils . integral_string? ENV [ 'PULL_REQUEST_ID' ]
34+ ENV [ 'PULL_REQUEST_ID' ] . to_i
35+ end
3436 end . pull_request? == false
3537 end
3638 end
3739 test '#pull_request_id' do
3840 assert do
3941 EnvPullRequest . new do
40- ENV [ 'PULL_REQUEST_ID' ] . to_i if ENV [ 'PULL_REQUEST_ID' ]
42+ if Utils . integral_string? ENV [ 'PULL_REQUEST_ID' ]
43+ ENV [ 'PULL_REQUEST_ID' ] . to_i
44+ end
4145 end . pull_request_id . nil?
4246 end
4347 end
@@ -58,14 +62,18 @@ def self.shutdown
5862 test '#pull_request?' do
5963 assert do
6064 EnvPullRequest . new do
61- ENV [ 'PULL_REQUEST_ID' ] . to_i if ENV [ 'PULL_REQUEST_ID' ]
65+ if Utils . integral_string? ENV [ 'PULL_REQUEST_ID' ]
66+ ENV [ 'PULL_REQUEST_ID' ] . to_i
67+ end
6268 end . pull_request? == true
6369 end
6470 end
6571 test '#pull_request_id' do
6672 assert do
6773 EnvPullRequest . new do
68- ENV [ 'PULL_REQUEST_ID' ] . to_i if ENV [ 'PULL_REQUEST_ID' ]
74+ if Utils . integral_string? ENV [ 'PULL_REQUEST_ID' ]
75+ ENV [ 'PULL_REQUEST_ID' ] . to_i
76+ end
6977 end . pull_request_id == pull_id
7078 end
7179 end
Original file line number Diff line number Diff line change 22
33module EnvPullRequest
44 class TestUtils < Test ::Unit ::TestCase
5- target = Class . new do
6- include Utils
7- end . new
8-
95 sub_test_case 'not integral' do
106 test 'nil' do
117 assert do
12- target . integral_string? ( nil ) == false
8+ Utils . integral_string? ( nil ) == false
139 end
1410 end
1511 test 'empty string' do
1612 assert do
17- target . integral_string? ( '' ) == false
13+ Utils . integral_string? ( '' ) == false
1814 end
1915 end
2016 test 'integer' do
2117 assert do
22- target . integral_string? ( 1 ) == false
18+ Utils . integral_string? ( 1 ) == false
2319 end
2420 end
2521 test 'decimal string' do
2622 assert do
27- target . integral_string? ( '1.1' ) == false
23+ Utils . integral_string? ( '1.1' ) == false
2824 end
2925 end
3026 end
3127 sub_test_case 'integral' do
3228 test '1' do
3329 assert do
34- target . integral_string? ( '1' ) == true
30+ Utils . integral_string? ( '1' ) == true
3531 end
3632 end
3733 test '10000000000000000' do
3834 assert do
39- target . integral_string? ( '10000000000000000' ) == true
35+ Utils . integral_string? ( '10000000000000000' ) == true
4036 end
4137 end
4238 end
You can’t perform that action at this time.
0 commit comments