Skip to content

Commit

Permalink
testcases added and rakefile updated
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkdoor committed Nov 3, 2008
1 parent 341f118 commit 95b0545
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 6 deletions.
27 changes: 21 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
#
# To change this template, choose Tools | Templates
# and open the template in the editor.
require "rake"
require "rake/testtask"
require "rake/rdoctask"
require "rake/clean"
require "rake/gempackagetask"

task :default => [ :test ]
task :test => [ :test_units ]

desc "run unit tests in test/unit"
rt = Rake::TestTask.new("test_units") do |t|
t.libs << "test/unit"
t.pattern = "test/test_*.rb"
t.verbose = true
end

require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
desc "create rdoc in /doc"
rd = Rake::RDocTask.new("doc") do |rd|
rd.main = "README"
rd.rdoc_files.include("README", "lib/*.rb")
rd.options << "--all"
rd.rdoc_dir = "rdoc"
end
15 changes: 15 additions & 0 deletions test/test_button.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require "test/unit"

require "rswing"

class TestButton < Test::Unit::TestCase
include RSwing::Components

def setup
@button = Button.new "hello world"
end

def test_events
assert(@button.respond_to?(:on_click), "no on_click method available!")
end
end
48 changes: 48 additions & 0 deletions test/test_container.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
require "test/unit"

require "rswing"

class TestContainer < Test::Unit::TestCase
include RSwing::Components

def setup
@container = Frame.new "my frame"
@button = Button.new "by button"
end

def test_indexer
btn = Button.new "my button", :belongs_to => @container, :name => :button
assert_equal(@container[:button], btn)
end

def test_add
@container.add @button
assert(@container.components.include?(@button), "container should have button!")
end

def test_remove
test_add
@container.remove @button
assert(! @container.components.include?(@button), "container should not have button!")
end

def test_add_if_requested
Container.add_if_requested @button, {}
assert(! @container.components.include?(@button), "container should not have button!")

Container.add_if_requested @button, :belongs_to => @container, :name => :new_button
assert(@container.components.include?(@button), "container now should have button!")
assert_not_nil(@container[:new_button], "container now should have button!")
end

def test_components
frame = Frame.new "my frame"
panel = Panel.new

frame.add @button
assert(frame.components.include?(@button), "frame should have button!")

panel.add @button
assert(panel.components.include?(@button), "panel should have button!")
end
end

0 comments on commit 95b0545

Please sign in to comment.