Skip to content

Commit

Permalink
Fix faker-ruby#2093 Allow custom start for forward date generator
Browse files Browse the repository at this point in the history
 *Allow set from as String or Date type
  • Loading branch information
luciagirasoles committed Jun 25, 2023
1 parent 35738db commit f86cb67
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
22 changes: 22 additions & 0 deletions test/faker/default/test_faker_date.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,28 @@ def test_forward
end
end

def test_forward_with_from_parameter
from = Date.parse('2012-01-01')

100.times do
random_date = @tester.forward(from: from, days: 5)

assert random_date > from, "Expected > \"#{from}\", but got #{random_date}"
end
end

def test_forward_with_string_parameter
from = '2012-01-01'

from_date = Date.parse(from)

100.times do
random_date = @tester.forward(from: from, days: 5)

assert random_date > from_date, "Expected > \"#{from}\", but got #{random_date}"
end
end

def test_backward
today = Date.today

Expand Down
2 changes: 0 additions & 2 deletions test/faker/default/test_faker_time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ def test_forward
end
end

# TODO: Add tests for Faker::Date.forward(from: "Thu, 22 Jun 2023", days: 10)

def test_backward
tomorrow = Date.today + 1

Expand Down

0 comments on commit f86cb67

Please sign in to comment.