Add Schedule

This commit is contained in:
Dzmitry Plashchynski
2015-03-03 15:11:19 +02:00
parent 2c78115ce7
commit 518160d5d9
9 changed files with 38 additions and 7 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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
View 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