File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -37,9 +37,9 @@ def update_db_required?
37
37
return false unless user_interaction? && local_db . outdated?
38
38
39
39
output ( '@notice' , msg : 'It seems like you have not updated the database for some time.' )
40
- print '[?] Do you want to update now? [Y]es [N]o, default: [N]'
40
+ response = Readline . readline ( '[?] Do you want to update now? [Y]es [N]o, default: [N] ' , true )
41
41
42
- /^y/i . match? ( Readline . readline )
42
+ !! /^y/i . match? ( response )
43
43
end
44
44
45
45
def update_db
Original file line number Diff line number Diff line change 106
106
107
107
context 'when the db is outdated' do
108
108
before do
109
+ allow ( core ) . to receive ( :user_interaction? ) . and_return ( true )
109
110
expect ( core . local_db ) . to receive ( :outdated? ) . ordered . and_return ( true )
110
111
expect ( core . formatter ) . to receive ( :output ) . with ( '@notice' , hash_including ( :msg ) , 'core' ) . ordered
111
- expect ( $stdout) . to receive ( :write ) . ordered # for the print()
112
112
end
113
113
114
114
context 'when a positive answer' do
115
- before { expect ( Readline ) . to receive ( :readline ) . and_return ( 'Yes' ) . ordered }
115
+ before do
116
+ expect ( Readline ) . to receive ( :readline ) . with ( '[?] Do you want to update now? [Y]es [N]o, default: [N] ' ,
117
+ true ) . and_return ( 'Yes' )
118
+ end
116
119
117
120
its ( :update_db_required? ) { should eql true }
118
121
end
119
122
120
123
context 'when a negative answer' do
121
- before { expect ( Readline ) . to receive ( :readline ) . and_return ( 'no' ) . ordered }
124
+ before do
125
+ expect ( Readline ) . to receive ( :readline ) . with ( '[?] Do you want to update now? [Y]es [N]o, default: [N] ' ,
126
+ true ) . and_return ( 'No' )
127
+ end
122
128
123
129
its ( :update_db_required? ) { should eql false }
124
130
end
You can’t perform that action at this time.
0 commit comments