Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #3 from peterhellberg/master

A few minitest specs and a rake task to run them (rake spec)
  • Loading branch information...
commit 636342fb488f8defebe872010c5255a55c44c968 2 parents addfb22 + 83ff630
hemanth.hm authored June 06, 2012
4  Rakefile
@@ -4,5 +4,9 @@ Rake::TestTask.new do |t|
4 4
   t.libs << 'test'
5 5
 end
6 6
 
  7
+Rake::TestTask.new(:spec) do |t|
  8
+  t.test_files = FileList['spec/**/*_spec.rb']
  9
+end
  10
+
7 11
 desc "Run tests"
8 12
 task :default => :test
15  spec/spec_helper.rb
... ...
@@ -0,0 +1,15 @@
  1
+# encoding: utf-8
  2
+
  3
+require 'minitest/autorun'
  4
+require 'minitest/spec'
  5
+
  6
+begin
  7
+  require 'minitest/pride'
  8
+rescue LoadError
  9
+  # Continue, but without colors
  10
+end
  11
+
  12
+# Note that relative requirements
  13
+# are only available in Ruby 1.9
  14
+#
  15
+require_relative '../lib/xkcd.rb'
32  spec/xkcd_spec.rb
... ...
@@ -0,0 +1,32 @@
  1
+# encoding: utf-8
  2
+
  3
+require_relative 'spec_helper.rb'
  4
+
  5
+# Specs for the XKCD class
  6
+#
  7
+describe XKCD do
  8
+
  9
+  # The comic class method
  10
+  #
  11
+  describe "comic" do
  12
+    it "should return the URI for a random comic" do
  13
+      XKCD.comic.must_match /^http:\/\/xkcd\.com\/\d{1,4}\/$/
  14
+    end
  15
+  end
  16
+
  17
+  # The get alias method
  18
+  #
  19
+  describe "get" do
  20
+    it "should return the URI for a random comic" do
  21
+      XKCD.get.must_match /^http:\/\/xkcd\.com\/\d{1,4}\/$/
  22
+    end
  23
+  end
  24
+
  25
+  # The img class method
  26
+  #
  27
+  describe "img" do
  28
+    it "should return the ALT text and URI of the image for a random comic" do
  29
+      XKCD.img.must_match /^.+ : http:\/\/imgs\.xkcd\.com\/comics\/.+\.(png|jpg)$/
  30
+    end
  31
+  end
  32
+end

0 notes on commit 636342f

Please sign in to comment.
Something went wrong with that request. Please try again.