-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Refute blank #707
Merged
Merged
Refute blank #707
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
54566c6
Added an implementation of blank? to String class
yakryder dfe3bba
Added a require to the file that adds blank? to String. Using blank?,…
yakryder 55b3af2
Switched monkey patch definition of blank? on String to monkey patch …
e2e8ba7
Made it so blank? will only be defined on Object if there is no exist…
77f2823
Merge branch 'master' of https://github.com/stympy/faker into refute_…
yakryder 9bdb52b
Removed Object monkey patch and replaced references to .blank? with .…
yakryder 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 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,6 @@ | ||
class Object | ||
def blank? | ||
return true if self.nil? || self.empty? | ||
false | ||
end | ||
end |
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 |
---|---|---|
@@ -1,37 +1,36 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb') | ||
|
||
class TestFakerHacker < Test::Unit::TestCase | ||
class TestFakerHacker < Test::Unit::TestCase | ||
def setup | ||
@hacker = Faker::Hacker | ||
@phrases = @hacker.phrases | ||
@phrases = @hacker.phrases | ||
end | ||
def test_phrases | ||
assert @phrases.size == 8 | ||
|
||
def test_phrases | ||
assert @phrases.size == 8 | ||
@phrases.each do |phrase| | ||
assert !phrase.nil? | ||
assert phrase != "" | ||
end | ||
end | ||
|
||
def test_noun | ||
refute phrase.blank? | ||
end | ||
end | ||
|
||
def test_noun | ||
assert @hacker.noun.match(/\w+/) | ||
end | ||
|
||
def test_abbreviation | ||
assert @hacker.abbreviation.match(/\w+/) | ||
end | ||
|
||
def test_adjective | ||
assert @hacker.adjective.match(/\w+/) | ||
end | ||
|
||
def test_verb | ||
assert @hacker.verb.match(/\w+/) | ||
end | ||
|
||
def test_ingverb | ||
assert @hacker.ingverb.match(/\w+/) | ||
end | ||
|
||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,49 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb') | ||
|
||
class TestFakerShakespeare < Test::Unit::TestCase | ||
class TestFakerShakespeare < Test::Unit::TestCase | ||
def setup | ||
@romeo_and_juliet = Faker::Shakespeare.romeo_and_juliet | ||
@king_richard_iii = Faker::Shakespeare.king_richard_iii | ||
@as_you_like_it = Faker::Shakespeare.as_you_like_it | ||
@hamlet = Faker::Shakespeare.hamlet | ||
end | ||
|
||
def test_quotes | ||
assert @romeo_and_juliet.size == 11 | ||
@romeo_and_juliet.each do |quotes| | ||
assert !quotes.nil? | ||
assert quotes != "" | ||
end | ||
|
||
assert @king_richard_iii.size == 8 | ||
@king_richard_iii.each do |quotes| | ||
assert !quotes.nil? | ||
assert quotes != "" | ||
end | ||
|
||
assert @as_you_like_it.size == 8 | ||
@as_you_like_it.each do |quotes| | ||
assert !quotes.nil? | ||
assert quotes != "" | ||
end | ||
|
||
assert @hamlet.size == 18 | ||
@hamlet.each do |quotes| | ||
assert !quotes.nil? | ||
assert quotes != "" | ||
end | ||
end | ||
|
||
assert @romeo_and_juliet.size == 11 | ||
@romeo_and_juliet.each do |quote| | ||
refute quote.blank? | ||
end | ||
|
||
assert @king_richard_iii.size == 8 | ||
@king_richard_iii.each do |quote| | ||
refute quote.blank? | ||
end | ||
|
||
assert @as_you_like_it.size == 8 | ||
@as_you_like_it.each do |quote| | ||
refute quote.blank? | ||
end | ||
|
||
assert @hamlet.size == 18 | ||
@hamlet.each do |quote| | ||
refute quote.blank? | ||
end | ||
end | ||
|
||
def test_as_you_like_it_quote | ||
assert Faker::Shakespeare.as_you_like_it_quote.match(/\w+/) | ||
end | ||
|
||
def test_king_richard_iii_quote | ||
assert Faker::Shakespeare.king_richard_iii_quote.match(/\w+/) | ||
end | ||
|
||
def test_romeo_and_juliet_quote | ||
assert Faker::Shakespeare.romeo_and_juliet_quote.match(/\w+/) | ||
end | ||
|
||
def test_hamlet_quote | ||
assert Faker::Shakespeare.hamlet_quote.match(/\w+/) | ||
end | ||
|
||
end |
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
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.
Some frameworks (rails, for example) already define this extension and overwriting this could affect someone else's implementation of it causing subtle and hard to find bugs... possibly based on gem loading order or dev/prod environment... maybe just require this in the
test_helper
? On the other hand, then if someone ended up usingObject#blank?
in the faker code somewhere, the tests could still pass but the gem wouldn't work except while running the tests, unless you had another gem defining this, and then it'd be based on someone else's implementation. Or maybe just check if it's already defined yet before redefining it. But I would question this in general because this could have effects beyond this gem. What functionality is this buying us for such a big risk? Using it in this way I think it at least needs stringent tests around it at a minimum.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.
what about
and
refute Tester.new(phrase).blank?
in the testThen I'd wonder why we would use a single refute