Skip to content

Commit

Permalink
Fix some warnings, make sure the tests ACTUALLY RUN coz rick broke it :)
Browse files Browse the repository at this point in the history
  • Loading branch information
courtenay committed Jan 14, 2009
1 parent 2e009b8 commit 768f2aa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/splam.rb
Expand Up @@ -41,7 +41,7 @@ def run(record)
end

def splam?(score)
score > threshold
score >= threshold
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/splam/rule.rb
Expand Up @@ -66,7 +66,7 @@ def add_score(points, reason)
@score ||= 0
if points != 0
@reasons << "#{name}: [#{points}#{" * #{weight}" if weight != 1}] #{reason}"
points = points * weight
points = points * weight.to_i
@score += points
end
end
Expand Down
10 changes: 5 additions & 5 deletions test/splam_test.rb
Expand Up @@ -64,20 +64,20 @@ def test_runs_plugins_with_specified_weighted_rules

def test_runs_conditions
f = FooCond.new
assert ! f.splam?
assert f.splam? # it IS spam, coz threshold is 0
end

def test_scores_spam_really_high
comment = Foo.new
Dir.glob(File.join(File.dirname(__FILE__), "fixtures", "comment", "spam", "*.txt")).each do |f|
comment = Foo.new
spam = File.open(f).read
comment.body = spam
# some spam have a lower threshold denoted by their filename
# trickier to detect
if f =~ /\/(\d+)_\w+\.txt/
if f =~ /\/(\d+)_.*\.txt/
Foo.splam_suite.threshold = $1.to_i
else
Foo.splam_suite.threshold = 99
Foo.splam_suite.threshold = 180
end
spam = comment.splam?
score = comment.splam_score
Expand All @@ -88,8 +88,8 @@ def test_scores_spam_really_high
end

def test_scores_ham_low
comment = Foo.new
Dir.glob(File.join(File.dirname(__FILE__), "fixtures", "comment", "ham", "*.txt")).each do |f|
comment = Foo.new
comment.body = File.open(f).read
spam = comment.splam?
score = comment.splam_score
Expand Down

0 comments on commit 768f2aa

Please sign in to comment.