From d147d5d0ebd9559875aaf5533b15a9ea2090e937 Mon Sep 17 00:00:00 2001 From: Brandon McGinty-Carroll Date: Mon, 9 Oct 2017 19:39:45 -0400 Subject: [PATCH] fix typo, change to making cleaner comparisons in spec --- spec/std/http/cookie_spec.cr | 12 ++++++------ src/http/cookie.cr | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/std/http/cookie_spec.cr b/spec/std/http/cookie_spec.cr index 0dc885510202..609320657b41 100644 --- a/spec/std/http/cookie_spec.cr +++ b/spec/std/http/cookie_spec.cr @@ -156,7 +156,7 @@ module HTTP describe "expiration_time" do it "sets expiration_time to be current when max-age=0" do cookie = parse_set_cookie("bla=1; max-age=0") - (Time.now - cookie.expiration_time.not_nil! <= 1.seconds).should be_true + (Time.now - cookie.expiration_time.not_nil!).should be.<= 1.seconds end it "sets expiration_time with old date" do @@ -166,14 +166,14 @@ module HTTP it "sets future expiration_time with max-age" do cookie = parse_set_cookie("bla=1; max-age=1") - (cookie.expiration_time.not_nil! > Time.now).should be_true + (cookie.expiration_time.not_nil!).should be.> Time.now end it "sets future expiration_time with max-age and future cookie creation time" do cookie = parse_set_cookie("bla=1; max-age=1") cookie_expiration = cookie.expiration_time(time_reference: Time.now + 20.seconds).not_nil! - (Time.now + 20.seconds < cookie_expiration).should be_true - (Time.now + 21.seconds >= cookie_expiration).should be_true + (Time.now + 20.seconds).should be.< cookie_expiration + (Time.now + 21.seconds).should be.>= cookie_expiration end it "sets future expiration_time with expires" do @@ -211,8 +211,8 @@ module HTTP it "sets past expiration_time with max-age and future time reference" do cookie = parse_set_cookie("bla=1; max-age=1") cookie_expiration = cookie.expiration_time(time_reference: Time.now - 20.seconds).not_nil! - (Time.now - cookie_expiration < 20.seconds).should be_true - (Time.now - cookie_expiration > 18.seconds).should be_true + (Time.now - 20.seconds).should be.< cookie_expiration + (Time.now - 18.seconds).should be.> cookie_expiration cookie_expired = cookie.expired?(time_reference: Time.now - 20.seconds) cookie_expired.should be_true end diff --git a/src/http/cookie.cr b/src/http/cookie.cr index f0a80292c49e..597d8b7cc061 100644 --- a/src/http/cookie.cr +++ b/src/http/cookie.cr @@ -50,7 +50,7 @@ module HTTP # Returns the `Time` at which this cookie will expire, or `nil` if it will not expire. # Uses *max-age* and *expires* values to calculate the time. # By default, this function uses the creation time of this cookie as the offset for max-age, if max-age is set. - # To use a different offset, provide a `Time` object to *time_Reference*. + # To use a different offset, provide a `Time` object to *time_reference*. def expiration_time(time_reference = @creation_time) if max_age = @max_age time_reference + max_age