Files
crono/spec/cli_spec.rb
Dzmitry Plashchynski 0ead66f626 Add logfile option
2015-03-03 19:01:33 +02:00

43 lines
1.0 KiB
Ruby

require "spec_helper"
require 'crono/cli'
class TestJob
def perform;end
end
describe Crono::CLI do
let(:cli) { Crono::CLI.instance }
describe "#run" 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)
expect(cli).to receive(:parse_options)
cli.run
end
end
describe "#run_job" do
it "should run job in separate thread" do
thread = cli.send(:run_job, TestJob).join
expect(thread).to be_stop
end
end
describe "#start_working_loop" do
it "should start working loop"
end
describe "#parse_options" do
it "should set cronotab" do
cli.send(:parse_options, ["--cronotab", "/tmp/cronotab.rb"])
expect(Crono.config.cronotab).to be_eql "/tmp/cronotab.rb"
end
it "should set logfile" do
cli.send(:parse_options, ["--logfile", "log/crono.log"])
expect(Crono.config.logfile).to be_eql "log/crono.log"
end
end
end