opening_hours 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/opening_hours.rb CHANGED
@@ -82,7 +82,7 @@ class OpeningHours
82
82
  end
83
83
 
84
84
  def now_open?
85
- calculate_deadline(0, Time.now.to_s) == Time.now.to_formatted_s(:rfc822)
85
+ calculate_deadline(0, Time.zone.now.to_s) == Time.zone.now.to_formatted_s(:rfc822)
86
86
  end
87
87
 
88
88
  def calculate_deadline(job_duration, start_date_time)
@@ -1,3 +1,3 @@
1
1
  class OpeningHours
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -197,4 +197,30 @@ describe OpeningHours do
197
197
  end
198
198
  end
199
199
 
200
+ context "now_open" do
201
+ context "on open hours" do
202
+ before do
203
+ open_time = Time.local(Date.today.year, Date.today.month, Date.today.day, Time.now.hour-1).strftime("%I:%M %p")
204
+ close_time = Time.local(Date.today.year, Date.today.month, Date.today.day, Time.now.hour+5).strftime("%I:%M %p")
205
+ @hours = OpeningHours.new(open_time, close_time, "Europe/Berlin")
206
+ end
207
+
208
+ it "should respond with right values" do
209
+ @hours.now_open?.should == true
210
+ end
211
+ end
212
+
213
+ context "on closed hours" do
214
+ before do
215
+ open_time = Time.local(Date.today.year, Date.today.month, Date.today.day, Time.now.hour+1).strftime("%I:%M %p")
216
+ close_time = Time.local(Date.today.year, Date.today.month, Date.today.day, Time.now.hour+5).strftime("%I:%M %p")
217
+ @hours = OpeningHours.new(open_time, close_time, "Europe/Berlin")
218
+ end
219
+
220
+ it "should respond with right values" do
221
+ @hours.now_open?.should == false
222
+ end
223
+ end
224
+ end
225
+
200
226
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opening_hours
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-14 00:00:00.000000000 Z
12
+ date: 2013-03-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec