From a1ca4907df8a3bc0e1b684bf9d59e857d1e128b6 Mon Sep 17 00:00:00 2001 From: Gaurish Sharma Date: Sat, 14 Nov 2015 01:45:24 +0530 Subject: [PATCH] Grammer & Style Tweaks as per feedback --- guides/CHANGELOG.md | 3 ++- guides/source/testing.md | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/guides/CHANGELOG.md b/guides/CHANGELOG.md index 3179746165..a58dfdcc37 100644 --- a/guides/CHANGELOG.md +++ b/guides/CHANGELOG.md @@ -1,4 +1,5 @@ -* New section in Testing Guide - Testing Time Sensitive Code +* New section in Testing Guide - Testing Time-Dependent Code + *Gaurish Sharma* * Add code of conduct to contributing guide diff --git a/guides/source/testing.md b/guides/source/testing.md index ea832e7176..ce9dd1f49d 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -1237,8 +1237,8 @@ Testing Time-Dependent Code --------------------------- You might have code in your rails app, that is time sensitive. For example, -you want to give some gifts to users but only after they have been a member for 1month -which is calculated from their activation date. to test such business logic in your tests +you want to give some gifts to users but only after they have been a member for month +which is calculated from their activation date. To test such business logic in your tests you will need to time travel in your tests. Fortunately, Rails provides inbuild helper methods which allow you time travel in your test code, @@ -1251,7 +1251,7 @@ Here is an example using [`travel_to`](http://api.rubyonrails.org/classes/Active user = User.create(name: 'Gaurish', activation_date: Date.new(2004, 10, 24)) assert_not user.applicable_for_gifting? # `activation_date` => Wed, 24 Nov 2004 travel_to Date.new(2004, 11, 24) do - assert_equal Date.new(2004, 10, 24), user.activation_date # inside the trave_to block `Date.current` is mocked + assert_equal Date.new(2004, 10, 24), user.activation_date # inside the travel_to block `Date.current` is mocked assert user.applicable_for_gifting? # `activation_date` => Sun, 24 Oct 2004 end assert_equal Date.new(2004, 10, 24), user.activation_date # Outside the block, changed are undone