Skip to content

Commit

Permalink
Fix #1 profane? works on text instead of single words
Browse files Browse the repository at this point in the history
  • Loading branch information
adambair committed Apr 11, 2011
1 parent c0d5745 commit 5c5578d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/profanity_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ class << self
def banned?(word = '')
dictionary.include?(word.downcase) if word
end
alias :profane? :banned?

def profane?(text = '')
text == clean(text) ? false : true
end

def clean(text, replace_method = '')
return text if text.blank?
Expand Down
7 changes: 7 additions & 0 deletions test/profanity_filter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,16 @@ def test_basic_profanity_filter_replaces_punctuation_spaced_profane_words
def test_knows_when_text_is_not_profane
assert !ProfanityFilter::Base.profane?('happy')
end

def test_knows_when_text_is_profane
assert ProfanityFilter::Base.profane?('fuck')
end

# Issue #1 https://github.com/intridea/profanity_filter/issues/1
def test_knows_when_text_contains_profanity
assert ProfanityFilter::Base.profane?('oh shit')
end

def test_knows_nil_is_not_profane
assert !ProfanityFilter::Base.profane?(nil)
end
Expand Down

0 comments on commit 5c5578d

Please sign in to comment.