Browse files

a couple tests to start with

  • Loading branch information...
1 parent 3db116f commit e8e6b30b7407576d57eb88cc2b2a656d1da26815 @holman committed May 3, 2010
Showing with 66 additions and 1 deletion.
  1. +7 −0 Rakefile
  2. +0 −1 bin/tissues
  3. +1 −0 lib/tissues.rb
  4. +20 −0 test/spec/mini.rb
  5. +13 −0 test/test_helper.rb
  6. +25 −0 test/test_patches.rb
View
7 Rakefile
@@ -79,7 +79,14 @@ end
#
#############################################################################
+require 'rake/testtask'
+Rake::TestTask.new(:test) do |test|
+ test.libs << 'lib' << 'test'
+ test.pattern = 'test/**/test_*.rb'
+ test.verbose = true
+end
+task :default => :test
#############################################################################
#
View
1 bin/tissues
@@ -1,5 +1,4 @@
#!/usr/bin/env ruby
-require 'vendor/octopi-0.2.9/lib/octopi'
require 'lib/tissues'
case ARGV[0]
View
1 lib/tissues.rb
@@ -3,6 +3,7 @@
require 'rubygems'
require 'things'
+require 'vendor/octopi-0.2.9/lib/octopi'
require 'tissues/helpers'
require 'tissues/patches'
require 'tissues/sync'
View
20 test/spec/mini.rb
@@ -0,0 +1,20 @@
+##
+# test/spec/mini 3
+# http://gist.github.com/25455
+# chris@ozmm.org
+# file:lib/test/spec/mini.rb
+#
+def context(*args, &block)
+ return super unless (name = args.first) && block
+ require 'test/unit'
+ klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
+ def self.test(name, &block)
+ define_method("test_#{name.gsub(/\W/,'_')}", &block) if block
+ end
+ def self.xtest(*args) end
+ def self.setup(&block) define_method(:setup, &block) end
+ def self.teardown(&block) define_method(:teardown, &block) end
+ end
+ (class << klass; self end).send(:define_method, :name) { name.gsub(/\W/,'_') }
+ klass.class_eval &block
+end
View
13 test/test_helper.rb
@@ -0,0 +1,13 @@
+require 'rubygems'
+require 'test/unit'
+require 'spec/mini'
+
+require 'tissues'
+
+begin
+ require 'redgreen'
+rescue LoadError
+end
+
+class Test::Unit::TestCase
+end
View
25 test/test_patches.rb
@@ -0,0 +1,25 @@
+require File.dirname(__FILE__) + '/test_helper'
+
+context "String" do
+ test "to_state" do
+ assert_equal :open, 'open'.to_state
+ assert_equal :closed, 'closed'.to_state
+ end
+
+ test "to_status" do
+ assert_equal :open, 'open'.to_status
+ assert_equal :completed, 'closed'.to_status
+ end
+end
+
+context "Things::Todo" do
+ test "number parsed if present" do
+ todo = Things::Todo.new(:name => '[#2] todo')
+ assert_equal ['2'], todo.number
+ end
+
+ test "number ignored if not present" do
+ todo = Things::Todo.new(:name => 'todo')
+ assert_equal nil, todo.number
+ end
+end

0 comments on commit e8e6b30

Please sign in to comment.