-
-
Save pat/139854 to your computer and use it in GitHub Desktop.
Revisions
-
pat revised this gist
Jul 3, 2009 . 2 changed files with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ # Post.by_day("next tuesday") def by_day(time = Time.zone.now, options = {}, &block) time = parse(time) by_star(time.utc.beginning_of_day, time.utc.end_of_day, options, &block) end alias_method :today, :by_day File renamed without changes. -
radar revised this gist
Jul 3, 2009 . 2 changed files with 31 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ # Examples: # Post.by_day # Post.by_day(Time.yesterday) # Post.by_day("next tuesday") def by_day(time = Time.zone.now, options = {}, &block) time = parse(time) by_star(time.beginning_of_day, time.end_of_day, options, &block) end alias_method :today, :by_day # Examples: # Post.yesterday # # 2 days ago: # Post.yesterday(Time.yesterday) # # day before next tuesday # Post.yesterday("next tuesday") def yesterday(time = Time.zone.now, options = {}, &block) time = parse(time) by_day(time.advance(:days => -1), options, &block) end # Examples: # Post.tomorrow # # 2 days from now: # Post.tomorrow(Time.tomorrow) # # day after next tuesday # Post.tomorrow("next tuesday") def tomorrow(time = Time.zone.now, options = {}, &block) time = parse(time) by_day(time.advance(:days => 1), options, &block) end File renamed without changes. -
radar revised this gist
Jul 3, 2009 . 1 changed file with 22 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ def find(*args) method = description_args.first.sub(' ', '_') Post.send(method, *args) end describe "today" do it "should show the post for tomorrow" do find("tomorrow").map(&:text).should include("Tomorrow's post") end end describe "yesterday" do it "should be able find yesterday, given a Date" do find(Date.today).map(&:text).should include("Yesterday's post") end end describe "tomorrow" do it "should be able find tomorrow, given a Date" do find(Date.today).map(&:text).should include("Tomorrow's post") end end -
radar revised this gist
Jul 3, 2009 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ Failures for by_star only occur (seemingly) in a positive timezone where the local time is in a day in the future from UTC. So in +1000 (Brisbane) these three specs only fail BEFORE 10am. After 10am it's a sea of wonderful green. ..................................F..F..F................................... -
radar revised this gist
Jul 3, 2009 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ Failures for by_star only occur (seemingly) in a positive timezone where the local time is in a day in the future from UTC. So in +1000 (Brisbane) these three specs only fail BEFORE 10am. After 10am it's a sea of wonderful green. ..................................F..F..F................................... 1) -
radar created this gist
Jul 3, 2009 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ ..................................F..F..F................................... 1) 'Post today should show the post for tomorrow' FAILED expected ["Today's post", "Today"] to include "Tomorrow's post" ./spec/by_star_spec.rb:197: 2) 'Post yesterday should be able find yesterday, given a Date' FAILED expected ["Today's post", "Today"] to include "Yesterday's post" ./spec/by_star_spec.rb:213: 3) 'Post tomorrow should be able find tomorrow, given a Date' FAILED expected [] to include "Tomorrow's post" ./spec/by_star_spec.rb:230: Finished in 0.263454 seconds 76 examples, 3 failures