Skip to content

Commit

Permalink
Removed unused cucumber. Added basic test for parser
Browse files Browse the repository at this point in the history
  • Loading branch information
sleroux committed Mar 11, 2013
1 parent 00bf9ad commit b285178
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 31 deletions.
1 change: 0 additions & 1 deletion Gemfile
Expand Up @@ -7,7 +7,6 @@ source "http://rubygems.org"
# Include everything needed to run rake, tests, features, etc.
group :development do
gem "rspec", "~> 2.3.0"
gem "cucumber", ">= 0"
gem "bundler" # , "~> 1.0.0"
gem "jeweler" # , "~> 1.5.2"
end
3 changes: 0 additions & 3 deletions Rakefile
Expand Up @@ -38,7 +38,4 @@ RSpec::Core::RakeTask.new(:rcov) do |spec|
spec.rcov = true
end

require 'cucumber/rake/task'
Cucumber::Rake::Task.new(:features)

task :default => :spec
9 changes: 0 additions & 9 deletions features/RubySpamAssassin.feature

This file was deleted.

Empty file.
13 changes: 0 additions & 13 deletions features/support/env.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/RubySpamAssassin/report_parser.rb
Expand Up @@ -10,7 +10,7 @@ def self.parse(report_text)
rules = []
pts_rules.each_with_index do |pts_rule, i|
rules << {
:pts => pts_rule.split(' ')[0],
:pts => pts_rule.split(' ')[0].to_f,
:rule => pts_rule.split(' ')[1],
:text => rule_texts[i + 1]
}
Expand Down
14 changes: 14 additions & 0 deletions spec/RubySpamAssassin/report_parser_spec.rb
@@ -0,0 +1,14 @@
require_relative '../spec_helper'

describe "ReportParser" do
it "should parse the report text into an informative hash" do
spam = File.read('spec/data/spam_test1.txt')
result = RubySpamAssassin::ReportParser.parse(spam)
result.length.equal?(6)

# Check contents of first one to make sure text/points are formatted correctly
result[0][:pts].equal?(0.5)
result[0][:rule].equal?('DATE_IN_PAST_24_48')
result[0][:text].equal?('Date: is 24 to 48 hours before Received: date')
end
end
1 change: 1 addition & 0 deletions spec/RubySpamAssassin/spam_client_spec.rb
@@ -0,0 +1 @@
require_relative '../spec_helper'
1 change: 1 addition & 0 deletions spec/RubySpamAssassin/spam_result_spec.rb
@@ -0,0 +1 @@
require_relative '../spec_helper'
4 changes: 1 addition & 3 deletions spec/RubySpamAssassin_spec.rb
@@ -1,7 +1,5 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe "Rubyspamassassin" do
it "fails" do
fail "hey buddy, you should probably rename this file and start specing for real"
end

end
39 changes: 39 additions & 0 deletions spec/data/spam_test1.txt
@@ -0,0 +1,39 @@
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on
scanner.com
X-Spam-Level: ***
X-Spam-Status: No, score=3.4 required=5.0 tests=DATE_IN_PAST_24_48,
HTML_MESSAGE,HTML_MIME_NO_HTML_TAG,INVALID_MSGID,MIME_HTML_ONLY,
UNPARSEABLE_RELAY autolearn=no version=3.3.2
Received: from dummyurl.com for <dummy@dummy.com>; Fri, 8 Mar 2013 14:53:15 -0500
Date: Thu, 7 Mar 2013 00:02:33 -0500
From: Dummy <dummy@dummy.com>
Reply-To: Dummy <dummy@dummy.com>
To: dummy@dummy.com
Message-Id: testdummy@dummy.com
Subject: Work Report
Mime-Version: 1.0
Content-Type: text/html; charset=utf-8
Auto-Submitted: auto-generated

Hey,

Was wondering if I could get a copy of the work report you made yesterday. Thanks!
Spam detection software, running on the system "scan1.blue.postageapp.com", has
identified this incoming email as possible spam. The original message
has been attached to this so you can view it (if it isn't spam) or label
similar future email. If you have any questions, see
the administrator of that system for details.

Content preview: Hey, Was wondering if I could get a copy of the work report
you made yesterday. Thanks! [...]

Content analysis details: (3.4 points, 5.0 required)

pts rule name description
---- ---------------------- --------------------------------------------------
0.5 DATE_IN_PAST_24_48 Date: is 24 to 48 hours before Received: date
0.0 HTML_MESSAGE BODY: HTML included in message
1.1 MIME_HTML_ONLY BODY: Message only has text/html MIME parts
0.6 HTML_MIME_NO_HTML_TAG HTML-only message, but there is no HTML tag
1.2 INVALID_MSGID Message-Id is not valid, according to RFC 2822
0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines
1 change: 0 additions & 1 deletion spec/spec_helper.rb
Expand Up @@ -8,5 +8,4 @@
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}

RSpec.configure do |config|

end

0 comments on commit b285178

Please sign in to comment.