Skip to content

Commit

Permalink
a couple tests to start with
Browse files Browse the repository at this point in the history
  • Loading branch information
holman committed May 3, 2010
1 parent 3db116f commit e8e6b30
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Rakefile
Expand Up @@ -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


############################################################################# #############################################################################
# #
Expand Down
1 change: 0 additions & 1 deletion bin/tissues
@@ -1,5 +1,4 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
require 'vendor/octopi-0.2.9/lib/octopi'
require 'lib/tissues' require 'lib/tissues'


case ARGV[0] case ARGV[0]
Expand Down
1 change: 1 addition & 0 deletions lib/tissues.rb
Expand Up @@ -3,6 +3,7 @@
require 'rubygems' require 'rubygems'
require 'things' require 'things'


require 'vendor/octopi-0.2.9/lib/octopi'
require 'tissues/helpers' require 'tissues/helpers'
require 'tissues/patches' require 'tissues/patches'
require 'tissues/sync' require 'tissues/sync'
Expand Down
20 changes: 20 additions & 0 deletions 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
13 changes: 13 additions & 0 deletions 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
25 changes: 25 additions & 0 deletions 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.