-
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.
In preparation for removing deprecations for certain generators, this commit documents the Deprecator and how to test deprecated generators. It also adds a unit test using newly added matchers based on Rails deprecation matchers. With this change, we can remove generators in a follow up PR while having the Deprecator covered and documented.
- Loading branch information
1 parent
130a504
commit c53bade
Showing
4 changed files
with
122 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../test_helper' | ||
|
||
class TestFakerDeprecation < Test::Unit::TestCase | ||
def test_using_a_deprecated_generator_returns_a_warning_message | ||
assert_deprecated do | ||
Faker::Dogs.say | ||
end | ||
|
||
assert_equal 'meow', Faker::Dogs.say | ||
end | ||
|
||
def test_using_a_non_deprecated_generator_does_not_return_a_warning_message | ||
assert_not_deprecated do | ||
Faker::Cats.say | ||
end | ||
assert_equal 'meow', Faker::Cats.say | ||
end | ||
|
||
def test_testing_a_deprecated_generator_with_skip_warning_does_not_return_a_warning_message | ||
actual_stdout, actual_stderr = capture_output do | ||
Faker::Deprecator.skip_warning do | ||
Faker::Dogs.say | ||
end | ||
end | ||
|
||
assert_empty(actual_stdout) | ||
assert_empty(actual_stderr) | ||
assert_equal 'meow', Faker::Dogs.say | ||
end | ||
|
||
def test_deprecated_with_skip_warning_does_not_generate_message | ||
Faker::Deprecator.skip_warning do | ||
assert_not_deprecated do | ||
Faker::Dogs.say | ||
end | ||
end | ||
|
||
assert_equal 'meow', Faker::Dogs.say | ||
end | ||
end | ||
|
||
module Faker | ||
class Cats < Base | ||
def self.say | ||
'meow' | ||
end | ||
end | ||
|
||
include Faker::Deprecator | ||
deprecate_generator('Dogs', Cats) | ||
end |
This file was deleted.
Oops, something went wrong.
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