mirror of
https://github.com/plashchynski/crono.git
synced 2026-03-21 08:59:36 +01:00
Add Schedule
This commit is contained in:
@@ -9,8 +9,9 @@ describe Crono::CLI do
|
||||
let(:cli) { Crono::CLI.instance }
|
||||
|
||||
describe "#run" do
|
||||
it "should try to initialize rails with #load_rails" do
|
||||
it "should try to initialize rails with #load_rails and start working loop" do
|
||||
expect(cli).to receive(:load_rails)
|
||||
expect(cli).to receive(:start_working_loop)
|
||||
cli.run
|
||||
end
|
||||
end
|
||||
@@ -21,4 +22,8 @@ describe Crono::CLI do
|
||||
expect(thread).to be_stop
|
||||
end
|
||||
end
|
||||
|
||||
describe "#start_working_loop" do
|
||||
it "should start working loop"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,9 +2,9 @@ require "spec_helper"
|
||||
|
||||
describe Crono::Config do
|
||||
describe "#initialize" do
|
||||
it "should initialize schedule with an empty array" do
|
||||
it "should initialize schedule" do
|
||||
@config = Crono::Config.instance
|
||||
expect(@config.schedule).to eql([])
|
||||
expect(@config.schedule).to be_a(Crono::Schedule)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,7 +6,7 @@ end
|
||||
|
||||
describe Crono::PerformerProxy do
|
||||
it "should add job and period to schedule" do
|
||||
expect(Crono::Config.instance.schedule).to receive(:add).with(TestJob, kind_of(Crono::Period))
|
||||
Crono.perform(TestJob).every(2.days, at: "15:30")
|
||||
expect(Crono::Config.instance.schedule).to_not be_empty
|
||||
end
|
||||
end
|
||||
|
||||
15
spec/schedule_spec.rb
Normal file
15
spec/schedule_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require "spec_helper"
|
||||
|
||||
class TestJob
|
||||
def perform;end
|
||||
end
|
||||
|
||||
describe Crono::Schedule do
|
||||
describe "#add" do
|
||||
it "should add an entry to schedule" do
|
||||
@schedule = Crono::Schedule.new
|
||||
@period = Crono::Period.new(1.day)
|
||||
@schedule.add(TestJob, @period)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user