Skip to content

Commit

Permalink
Added more unit-test for working with list
Browse files Browse the repository at this point in the history
  • Loading branch information
ngiger committed Dec 18, 2013
1 parent 9f4f20b commit e64fa35
Show file tree
Hide file tree
Showing 7 changed files with 369 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
pkg/
ext/htmlgrid/Makefile
pkg/
.bundle/
5 changes: 3 additions & 2 deletions .travis.yml
@@ -1,6 +1,7 @@
language: ruby
before_install:
- gem install bundler

bundler_args: --without debugger

notifications:
email:
- ngiger@ywesee.com
Expand Down
6 changes: 6 additions & 0 deletions Gemfile
Expand Up @@ -15,6 +15,12 @@ end
group :development do
gem 'racc'
gem 'travis-lint'
gem 'minitest-reporters'
# gem 'pry'
# gem 'pry-debugger'
end

group :debugger do
gem 'pry'
gem 'pry-debugger'
end
29 changes: 28 additions & 1 deletion Gemfile.lock
Expand Up @@ -3,14 +3,24 @@ GEM
specs:
ansi (1.4.3)
builder (3.2.2)
docile (1.1.0)
coderay (1.1.0)
columnize (0.3.6)
debugger (1.6.3)
columnize (>= 0.3.1)
debugger-linecache (~> 1.2.0)
debugger-ruby_core_source (~> 1.2.4)
debugger-linecache (1.2.0)
debugger-ruby_core_source (1.2.4)
docile (1.1.1)
ffi (1.9.3-java)
hashie (2.0.5)
hashr (0.0.22)
hoe (3.7.1)
rake (>= 0.8, < 11.0)
hoe-travis (1.2)
hoe (~> 3.0)
travis-lint (~> 1.2)
method_source (0.8.2)
minitest (5.0.8)
minitest-reporters (1.0.0)
ansi
Expand All @@ -21,6 +31,18 @@ GEM
powerbar (1.0.11)
ansi (~> 1.4.0)
hashie (>= 1.1.0)
pry (0.9.12.4)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
pry (0.9.12.4-java)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
spoon (~> 0.0)
pry-debugger (0.2.2)
debugger (~> 1.3)
pry (~> 0.9.10)
racc (1.4.10)
rake (10.1.0)
sbsm (1.2.3)
Expand All @@ -29,6 +51,9 @@ GEM
multi_json
simplecov-html (~> 0.8.0)
simplecov-html (0.8.0)
slop (3.4.7)
spoon (0.0.4)
ffi
test-unit (2.5.5)
travis-lint (1.7.0)
hashr (~> 0.0.22)
Expand All @@ -42,6 +67,8 @@ DEPENDENCIES
hoe-travis
minitest
minitest-reporters
pry
pry-debugger
racc
rake
sbsm
Expand Down
11 changes: 5 additions & 6 deletions Rakefile
Expand Up @@ -29,7 +29,6 @@ Hoe.spec('htmlgrid') do |p|
p.developer('Masaomi Hatakeyama, Zeno R.R. Davatz','mhatakeyama@ywesee.com, zdavatz@ywesee.com')
p.license('GPL v2.1')
p.remote_rdoc_dir = 'htmlgrid'
p.extra_deps << ['ruby-ole', '>=1.0']
end

if /java/i.match(RUBY_PLATFORM)
Expand All @@ -42,11 +41,11 @@ else
task :test => :rebuild
end

#require 'minitest/reporters'
#MiniTest::Reporters.use!
require 'minitest/reporters'
MiniTest::Reporters.use!

#Rake::TestTask.new do |t|
# t.pattern = "test/test_*.rb"
#end
Rake::TestTask.new do |t|
t.pattern = "test/test_*.rb"
end

# vim: syntax=ruby
75 changes: 75 additions & 0 deletions test/test_add_row.rb
@@ -0,0 +1,75 @@
#!/usr/bin/env ruby
#encoding: utf-8
$: << File.expand_path('../lib', File.dirname(__FILE__))
$: << File.dirname(__FILE__)

require 'test/unit'
require 'stub/cgi'
require 'htmlgrid/composite'
require 'htmlgrid/inputtext'
require 'htmlgrid/form'

class StubComposite < HtmlGrid::Composite
attr_writer :container
COMPONENTS = {
[0,0,1] => :foo,
}
LABELS = true
SYMBOL_MAP = {
:bar => HtmlGrid::InputText,
}
attr_reader :model, :session
public :resolve_offset, :labels?
def init
@barcount=0
super
end
def foo(model)
1.upto(2).each { |idx|
@grid.add(baz(model), 0, idx, 0)
}
"Foo"
end
def baz(model)
@barcount += 1
"Baz#{@barcount}"
end
end
class StubCompositeModel
end
class StubComposite2Model
end
class StubCompositeLookandfeel
def attributes(key)
{}
end
def lookup(key)
end
def base_url
'http://www.oddb.org/de/gcc'
end
end
class StubCompositeSession
def lookandfeel
StubCompositeLookandfeel.new
end
def error(key)
end
end
class StubCompositeForm < HtmlGrid::Form
COMPONENTS = {
[0,0] => StubComposite
}
EVENT = :foo
end

class TestComposite < Test::Unit::TestCase
def setup
@composite = StubComposite.new([StubComposite2Model.new, StubCompositeModel.new],
StubCompositeSession.new)
end
def test_to_html
expected = '<TABLE cellspacing="0"><TR><TD>Foo</TD></TR><TR><TD>Baz1</TD></TR><TR><TD>Baz2</TD></TR></TABLE>'
assert_equal(expected, @composite.to_html(CGI.new))
end
end

0 comments on commit e64fa35

Please sign in to comment.