Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removed unused cucumber. Added basic test for parser

  • Loading branch information...
commit b2851788b9ed6d0373c9922fa6c56b0f075fc590 1 parent 00bf9ad
@sleroux sleroux authored
View
1  Gemfile
@@ -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
View
3  Rakefile
@@ -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
View
9 features/RubySpamAssassin.feature
@@ -1,9 +0,0 @@
-Feature: something something
- In order to something something
- A user something something
- something something something
-
- Scenario: something something
- Given inspiration
- When I create a sweet new gem
- Then everyone should see how awesome I am
View
0  features/step_definitions/RubySpamAssassin_steps.rb
No changes.
View
13 features/support/env.rb
@@ -1,13 +0,0 @@
-require 'bundler'
-begin
- Bundler.setup(:default, :development)
-rescue Bundler::BundlerError => e
- $stderr.puts e.message
- $stderr.puts "Run `bundle install` to install missing gems"
- exit e.status_code
-end
-
-$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
-require 'RubySpamAssassin'
-
-require 'rspec/expectations'
View
2  lib/RubySpamAssassin/report_parser.rb
@@ -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]
}
View
14 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
View
1  spec/RubySpamAssassin/spam_client_spec.rb
@@ -0,0 +1 @@
+require_relative '../spec_helper'
View
1  spec/RubySpamAssassin/spam_result_spec.rb
@@ -0,0 +1 @@
+require_relative '../spec_helper'
View
4 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
View
39 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
View
1  spec/spec_helper.rb
@@ -8,5 +8,4 @@
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
RSpec.configure do |config|
-
end
Please sign in to comment.
Something went wrong with that request. Please try again.