forked from Homebrew/brew
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Homebrew#16259 from dduugg/vendor-blank
Implement ActiveSupport's Object#blank? directly
- Loading branch information
Showing
160 changed files
with
131 additions
and
20,625 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 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
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,50 @@ | ||
# frozen_string_literal: true | ||
|
||
require "extend/blank" | ||
|
||
describe Object do | ||
let(:empty_true) do | ||
Class.new(described_class) do | ||
def empty? | ||
0 | ||
end | ||
end | ||
end | ||
let(:empty_false) do | ||
Class.new(described_class) do | ||
def empty? | ||
nil | ||
end | ||
end | ||
end | ||
let(:blank) { [empty_true.new, nil, false, "", " ", " \n\t \r ", " ", "\u00a0", [], {}] } | ||
let(:present) { [empty_false.new, described_class.new, true, 0, 1, "a", [nil], { nil => 0 }, Time.now] } | ||
|
||
describe ".blank?" do | ||
it "checks if an object is blank" do | ||
blank.each { |v| expect(v.blank?).to be true } | ||
present.each { |v| expect(v.blank?).to be false } | ||
end | ||
|
||
it "checks if an object is blank with bundled string encodings" do | ||
Encoding.list.reject(&:dummy?).each do |encoding| | ||
expect(" ".encode(encoding).blank?).to be true | ||
expect("a".encode(encoding).blank?).to be false | ||
end | ||
end | ||
end | ||
|
||
describe ".present?" do | ||
it "checks if an object is present" do | ||
blank.each { |v| expect(v.present?).to be false } | ||
present.each { |v| expect(v.present?).to be true } | ||
end | ||
end | ||
|
||
describe ".presence" do | ||
it "returns the object if present, or nil" do | ||
blank.each { |v| expect(v.presence).to be_nil } | ||
present.each { |v| expect(v.presence).to be v } | ||
end | ||
end | ||
end |
21 changes: 0 additions & 21 deletions
21
Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.2.2/LICENSE.txt
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
...endor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent-ruby.rb
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.