Open
Description
Hi,
I started using ruby-clock in a Rails project and so far I love it, great job!
I have one question though: Is it possible to directly execute specific Clockfile tasks synchronously, as in 'now'?
I think this would make a lot of sense for integration testing. For example,
# app/models/user.rb
# ...
def self.create_remote_users
where(state: 'pending').each do |user|
if MyRemoteApi.create_user(...) ; user.activate! ; end
end
end
# Clockfile
every '1 minute' do
# ... more minutely jobs
User.create_remote_users
end
# tests/integration/user_integration_test.rb
# this should create a User account
# A cronjob then checks for new Users and creates a user profile on a remote system too
test 'does create remote user too' do
post '/signup', params: {...}
assert_response :success
RubyClock.execute_tasks_for.every '1 minute' # or RubyClock.execute_tasks_for.cron '0 0 0 * *' , or ...
assert_equal 'success', MyRemoteApi.login_as(...)
end
This way, I can not just check if my async remote APi job works well (this would be a unit test) but also if I call it at the right point and if it is included in the correct cronjob.
Is something like this possible with ruby-clock? If not, do you think it makes sense to implement it?
Metadata
Metadata
Assignees
Labels
No labels