forked from clio/ten_years_rails
-
Notifications
You must be signed in to change notification settings - Fork 42
Fix Ruby 2.3 compatibility in DeprecationTracker #180
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
df305e9
Fix: compare mode does not run on buckets
JuanVqz 972fdbb
fix: remove space in block parameter for Ruby 2.3 compatibility
JuanVqz a9d47ae
fix(deprecation_tracker): use deprecation_messages in compare, not no…
JuanVqz d959bbc
test: add explicit tests for normalized_deprecation_messages
JuanVqz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -184,7 +184,7 @@ def compare | |
|
|
||
| changed_buckets = [] | ||
|
|
||
| normalized_deprecation_messages.each do |bucket, messages| | ||
| deprecation_messages.each do |bucket, messages| | ||
| if stored[bucket] != messages | ||
| changed_buckets << bucket | ||
| end | ||
|
|
@@ -252,7 +252,7 @@ def normalized_deprecation_messages | |
|
|
||
| # not using `to_h` here to support older ruby versions | ||
| {}.tap do |h| | ||
| normalized.reject {|_key, value| value.empty? }.sort_by {|key, _value| key }.each do |k ,v| | ||
| normalized.reject {|_key, value| value.empty? }.sort_by {|key, _value| key }.each do |k, v| | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TIL: This comma was getting Ruby 2.3 to fail |
||
| h[k] = v | ||
| end | ||
| end | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -226,6 +226,60 @@ | |
| end | ||
| end | ||
|
|
||
| describe "#normalized_deprecation_messages" do | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding some tests to exercise the |
||
| it "merges stored and current messages" do | ||
| setup_tracker = DeprecationTracker.new(shitlist_path) | ||
| setup_tracker.bucket = "bucket 1" | ||
| setup_tracker.add("a") | ||
| setup_tracker.save | ||
|
|
||
| subject = DeprecationTracker.new(shitlist_path) | ||
| subject.bucket = "bucket 2" | ||
| subject.add("b") | ||
|
|
||
| normalized = subject.normalized_deprecation_messages | ||
| expect(normalized).to eq( | ||
| "bucket 1" => ["a"], | ||
| "bucket 2" => ["b"] | ||
| ) | ||
| end | ||
|
|
||
| it "sorts messages per bucket" do | ||
| subject = DeprecationTracker.new(shitlist_path) | ||
| subject.bucket = "bucket 1" | ||
| subject.add("c") | ||
| subject.add("a") | ||
| subject.add("b") | ||
|
|
||
| normalized = subject.normalized_deprecation_messages | ||
| expect(normalized["bucket 1"]).to eq(["a", "b", "c"]) | ||
| end | ||
|
|
||
| it "rejects empty buckets" do | ||
| setup_tracker = DeprecationTracker.new(shitlist_path) | ||
| setup_tracker.bucket = "bucket 1" | ||
| setup_tracker.add("a") | ||
| setup_tracker.save | ||
|
|
||
| subject = DeprecationTracker.new(shitlist_path) | ||
| # Don't add anything, just read | ||
|
|
||
| normalized = subject.normalized_deprecation_messages | ||
| expect(normalized).to eq("bucket 1" => ["a"]) | ||
| end | ||
|
|
||
| it "sorts by bucket name" do | ||
| subject = DeprecationTracker.new(shitlist_path) | ||
| subject.bucket = "z_bucket" | ||
| subject.add("a") | ||
| subject.bucket = "a_bucket" | ||
| subject.add("b") | ||
|
|
||
| normalized = subject.normalized_deprecation_messages | ||
| expect(normalized.keys).to eq(["a_bucket", "z_bucket"]) | ||
| end | ||
| end | ||
|
|
||
| describe "#after_run" do | ||
| let(:shitlist_path) { "some_path" } | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuanVqz Why is this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@etagwerker @arielj is not needed but is nice to have, using the
deprecation_messagessaves thecompareprocess to run the processes made inside ofnormalized_deprecation_messages.