Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The examples for Faker::Date.between do not work #2056

Closed
uchagani opened this issue Jun 12, 2020 · 4 comments
Closed

The examples for Faker::Date.between do not work #2056

uchagani opened this issue Jun 12, 2020 · 4 comments

Comments

@uchagani
Copy link

Describe the bug

The examples for Faker::Date.between(from: 2.days.ago, to: Date.today) and Faker::Date.between_except(from: 1.year.ago, to: 1.year.from_now, excepted: Date.today) do not work.

[9] pry(main)> Faker::Date.between(from: 2.days.ago, to: Date.today)
NoMethodError: undefined method `days' for 2:Integer
from (pry):9:in `<main>'

To Reproduce

# Gemfile
source 'https://rubygems.org
gem 'faker'
# test.rb
require 'faker'

date_between = Faker::Date.between(from: 2.days.ago, to: Date.today)

puts date_between.to_s

Expected behavior

I should see a date between the given arguments passed to between

Additional context

My guess is that these examples require activesupport in order to get the extensions on the integer class.

@Zeragamba Zeragamba changed the title Issue title goes here The examples for Faker::Date.between do not work Jun 12, 2020
@danielTiringer
Copy link
Contributor

The methods (.days ago and alike) are part of activesupport. Requiring active_support/time makes the example above work.
Should this be mentioned in the documentation (YARD and /docs) as a solution, or should we investigate alternative solutions?

@uchagani
Copy link
Author

uchagani commented Jun 14, 2020 via email

@Zeragamba
Copy link
Contributor

I think it would be good to update the examples to show both a Rails and Rails-less.

@koic
Copy link
Member

koic commented Jun 18, 2020

The issue has been resolved by #2061.

@koic koic closed this as completed Jun 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants