Class: TestCrontabAdding
- Inherits:
-
MiniTest::Unit::TestCase
- Object
- MiniTest::Unit::TestCase
- TestCrontabAdding
show all
- Includes:
- Dorkbox
- Defined in:
- lib/dorkbox_test.rb
Constant Summary
Constants included
from Dorkbox
Dorkbox::CONFLICT_STRING, Dorkbox::DORKBOX_CONFIG_PATH, Dorkbox::DORKBOX_CRONTAB_COMMENT, Dorkbox::GITIGNORE
Instance Method Summary
collapse
Methods included from Dorkbox
#align_client_ref_to_master, #cleanup_tracked, #configure_client_id, #connect, #create, #create_new_client_id, #enable_dorkbox_cronjob, #retrieve_client_id, #sync, #sync_tracked, #track
Instance Method Details
#setup ⇒ Object
177
178
179
180
181
182
183
184
|
# File 'lib/dorkbox_test.rb', line 177
def setup
begin
@save_user_crontab = c('crontab -l 2>/dev/null')
rescue
@save_user_crontab = nil
end
`crontab -r || /bin/true`
end
|
#teardown ⇒ Object
186
187
188
189
190
191
192
193
194
195
196
|
# File 'lib/dorkbox_test.rb', line 186
def teardown
if @save_user_crontab.nil?
`crontab -r`
else
tmp = Tempfile.new('dorkbox-temp')
tmp.puts(@save_user_crontab)
tmp.flush()
`crontab #{tmp.path}`
tmp.close()
end
end
|
#test_dorkbox_cron_is_enabled_when_crontab_empty ⇒ Object
198
199
200
201
202
|
# File 'lib/dorkbox_test.rb', line 198
def test_dorkbox_cron_is_enabled_when_crontab_empty
enable_dorkbox_cronjob()
v = c('crontab -l')
assert(v.scan(/#{DORKBOX_CRONTAB_COMMENT}/).size == 2)
end
|
#test_dorkbox_cron_is_not_duplicated_if_already_there ⇒ Object
204
205
206
207
208
209
|
# File 'lib/dorkbox_test.rb', line 204
def test_dorkbox_cron_is_not_duplicated_if_already_there
enable_dorkbox_cronjob()
enable_dorkbox_cronjob('asdasd')
v = c('crontab -l')
assert(v.scan(/#{DORKBOX_CRONTAB_COMMENT}/).size == 2)
end
|
#test_dorkbox_cron_is_updated_if_already_there ⇒ Object
211
212
213
214
215
216
217
|
# File 'lib/dorkbox_test.rb', line 211
def test_dorkbox_cron_is_updated_if_already_there
enable_dorkbox_cronjob()
enable_dorkbox_cronjob('asdasd')
v = c('crontab -l')
assert(v.scan(/#{DORKBOX_CRONTAB_COMMENT}/).size == 2)
assert(v.scan(/asdasd/).size == 1)
end
|