Skip to content

Commit

Permalink
Added simple tests, fixed examples
Browse files Browse the repository at this point in the history
git-svn-id: http://ruby-snarl.rubyforge.org/svn/trunk@8 4cdc1f07-391a-0410-901e-8ba36eb30a96
  • Loading branch information
phurley committed Aug 8, 2006
1 parent f358ada commit 22eb2ce
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/example3.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'snarl'

clock_message = Snarl.new('Time', Time.now.to_s, 0)
clock_message = Snarl.new('Time', Time.now.to_s, nil, Snarl::NO_TIMEOUT)
while clock_message.visible?
clock_message.update('Time', Time.now.to_s)
sleep 0.75
Expand Down
2 changes: 1 addition & 1 deletion examples/example4.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require'snarl'

m = Snarl.new("Count down", "Here we go", 0)
m = Snarl.new("Count down", "Here we go", nil, Snarl::NO_TIMEOUT)

10.downto(0) do |i|
m.update("Count down", "T Minus #{i} and counting")
Expand Down
2 changes: 1 addition & 1 deletion ruby-snarl.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ require 'rubygems'

spec = Gem::Specification.new do |s|
s.name = "ruby-snarl"
s.version = "0.0.6"
s.version = "0.0.7"
s.author = "Patrick Hurley"
s.email = "phurley@gmail.com"
s.homepage = "http://ruby-snarl.rubyforge.org/"
Expand Down
47 changes: 47 additions & 0 deletions test/test_snarl.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
require "snarl"
# require 'test/unit' unless defined? $ZENTEST and $ZENTEST

class TestSnarl < Test::Unit::TestCase

def test_new_api
assert(Snarl.new('title'))
assert(Snarl.new('title', 'msg'))

assert_raises(TypeError) { Snarl.new('title', 'msg', 0) }
assert(Snarl.new('title', 'msg', nil))
assert(Snarl.new('title', 'msg', 'missing_file'))
assert(Snarl.new('title', 'short', nil, 1))
end

def test_show_api
assert(Snarl.show_message('title'))
assert(Snarl.show_message('title', 'msg'))

assert_raises(TypeError) { Snarl.show_message('title', 'msg', 0) }
assert(Snarl.show_message('title', 'msg', nil))
assert(Snarl.show_message('title', 'msg', 'missing_file'))
assert(Snarl.show_message('title', 'short', nil, 1))
end

def test_update_api
assert(s = Snarl.new('title'))
assert(s.update('new title'))
assert(s.update('title', 'msg'))

assert_raises(TypeError) { s.update('title', 'msg', 0) }
assert(s.update('title', 'msg', nil))
assert(s.update('title', 'msg', 'missing_file'))
assert(s.update('title', 'short', nil, 1))
end

def test_visible
assert(s = Snarl.new('title', 'hold me', nil, 1))
assert(s.visible?)
assert(s.hide)
end

# this one is a little fragile, but it passes right now...
def test_version
assert_equal("1.1", Snarl.version)
end
end

0 comments on commit 22eb2ce

Please sign in to comment.