-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add warn for positional arguments when using Faker 2.0 (#1698)
## Summary An `ArgumentError` occurred when upgrading to Faker 2.0. I didn't know what argument to change until I arrived at the changelog. https://github.com/faker-ruby/faker/blob/v2.1.2/CHANGELOG.md#important-note This PR will warn users what keyword arguments should be changed when positional arguments is used. This reduces users pain and makes upgrades easier. The following is an example. ```console % cat example.rb require 'faker' Faker::Address.zip_code('NY') ``` ### Before ```console % bundle exec ruby example.rb Traceback (most recent call last): 1: from example.rb:3:in `<main>' /Users/koic/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/faker-2.1.2/lib/faker/default/address.rb:32:in `zip_code': wrong number of arguments (given 1, expected 0) (ArgumentError) ``` ### After ```console % bundle exec ruby example.rb example.rb:3: Passing `state_abbreviation` with the 1st argument of `Address.zip_code` is deprecated. Use keyword argument like `Address.zip_code(state_abbreviation: ...)` instead. ``` ## Other Information The `uplevel` keyword argument of `warn` method is a feature from Ruby 2.5. Faker supports Ruby 2.3 orh higehr, so it is emulated with `warn_with_uplevel` method.
- Loading branch information
Showing
48 changed files
with
1,359 additions
and
143 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Oops, something went wrong.