deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject [5/6] git commit: * tests/helpers/common.rb: add a assert_uri assertion
Date Tue, 14 Aug 2012 21:47:25 GMT
* tests/helpers/common.rb: add a assert_uri assertion

We deal with lots of URI's and need a way to check they are valid


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/90c1c9dc
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/90c1c9dc
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/90c1c9dc

Branch: refs/heads/master
Commit: 90c1c9dc10a3193a8224356c910983f709f3db9a
Parents: 10ab7ae
Author: David Lutterkort <lutter@redhat.com>
Authored: Fri Aug 10 17:49:41 2012 -0700
Committer: David Lutterkort <lutter@redhat.com>
Committed: Tue Aug 14 14:44:18 2012 -0700

----------------------------------------------------------------------
 tests/helpers/common.rb |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/90c1c9dc/tests/helpers/common.rb
----------------------------------------------------------------------
diff --git a/tests/helpers/common.rb b/tests/helpers/common.rb
index 5b3bcfb..fd627a2 100644
--- a/tests/helpers/common.rb
+++ b/tests/helpers/common.rb
@@ -67,3 +67,20 @@ module Deltacloud
     end
   end
 end
+
+# Add an assertion for URI's
+module MiniTest::Assertions
+  def assert_uri(obj, msg = nil)
+    msg = message(msg) { "Expected #{mu_pp(obj)} to be a valid URI" }
+    refute_nil obj, msg
+    refute_empty obj, msg
+    begin
+      u = URI.parse(obj)
+      refute_nil u.path, msg
+    rescue => e
+      fail "Could not parse URI #{mu_pp(obj)}"
+    end
+  end
+end
+
+MiniTest::Expectations::infect_an_assertion :assert_uri, :must_be_uri, :unary


Mime
View raw message