Add option 'at'

This commit is contained in:
Dzmitry Plashchynski
2015-03-01 16:28:19 +02:00
parent b3a26ba7d3
commit 0cccc4b606
4 changed files with 33 additions and 4 deletions

View File

@@ -13,6 +13,23 @@ describe Periodicity::Period do
@period = Periodicity::Period.new(2.day)
expect(@period.next).to be_eql(2.day.from_now)
end
it "should set time to 'at' time as a string" do
@period = Periodicity::Period.new(2.day, at: "15:20")
expect(@period.next).to be_eql(2.day.from_now.change(hour: 15, min: 20))
end
it "should set time to 'at' time as a hash" do
at = {hour: 18, min: 45}
@period = Periodicity::Period.new(2.day, at: at)
expect(@period.next).to be_eql(2.day.from_now.change(at))
end
it "should raise error when 'at' is wrong" do
expect {
@period = Periodicity::Period.new(2.day, at: 1)
}.to raise_error("Unknown 'at' format")
end
end
end
end

View File

@@ -4,6 +4,5 @@ Bundler.setup
require 'timecop'
require 'periodicity'
RSpec.configure do |config|
end