whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [whimsy] branch master updated: Add some initial rspec tests
Date Sat, 02 Mar 2019 15:05:03 GMT
This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new f0f9728  Add some initial rspec tests
f0f9728 is described below

commit f0f97288a4179c1f8a56a5c3bb66ae233d97d40d
Author: Sebb <sebb@apache.org>
AuthorDate: Sat Mar 2 15:05:02 2019 +0000

    Add some initial rspec tests
    
    Not yet in Travis.
---
 .rspec                         |  3 +++
 lib/spec/README.md             |  7 +++++++
 lib/spec/lib/mail/mail_spec.rb | 25 +++++++++++++++++++++++++
 lib/spec/spec_helper.rb        |  1 +
 4 files changed, 36 insertions(+)

diff --git a/.rspec b/.rspec
new file mode 100644
index 0000000..ab695a0
--- /dev/null
+++ b/.rspec
@@ -0,0 +1,3 @@
+# ensure that rspec works OK with child spec directory
+
+-I /srv/whimsy/lib/spec
diff --git a/lib/spec/README.md b/lib/spec/README.md
new file mode 100644
index 0000000..879924c
--- /dev/null
+++ b/lib/spec/README.md
@@ -0,0 +1,7 @@
+Test cases (using rspec) for the library
+
+Run the tests:
+
+$ rspec [-I lib/spec] lib
+
+The -I flag and its parameter can be omitted if they are added to the .rspec file
diff --git a/lib/spec/lib/mail/mail_spec.rb b/lib/spec/lib/mail/mail_spec.rb
new file mode 100644
index 0000000..82ca6e5
--- /dev/null
+++ b/lib/spec/lib/mail/mail_spec.rb
@@ -0,0 +1,25 @@
+# encoding: utf-8
+# frozen_string_literal: true
+require 'spec_helper'
+require 'whimsy/asf'
+
+describe ASF::Mail do
+  
+  describe "ASF::Mail.to_canonical" do
+    it "should return address unaltered for invalid emails" do
+      email = 'textwithnoATsign'
+      expect(ASF::Mail.to_canonical(email)).to eq(email)
+      email = 'textwithtrailing@'
+      expect(ASF::Mail.to_canonical(email)).to eq(email)
+      email = '@textwithleadingAT'
+      expect(ASF::Mail.to_canonical(email)).to eq(email)
+    end    
+    it "should return address with downcased domain for valid emails" do
+      expect(ASF::Mail.to_canonical('ABC@DEF')).to eq('ABC@def')
+    end    
+    it "should return address with downcased domain and canonicalised name for Google emails"
do
+      expect(ASF::Mail.to_canonical('A.B.C+123@GMail.com')).to eq('abc@gmail.com')
+    end    
+  end
+
+end
diff --git a/lib/spec/spec_helper.rb b/lib/spec/spec_helper.rb
new file mode 100644
index 0000000..8db5339
--- /dev/null
+++ b/lib/spec/spec_helper.rb
@@ -0,0 +1 @@
+$LOAD_PATH.unshift '/srv/whimsy/lib'


Mime
View raw message