htmlgrid 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/History.txt +8 -1
  3. data/Manifest.txt +1 -1
  4. data/lib/htmlgrid/component.rb +3 -11
  5. data/lib/htmlgrid/composite.rb +5 -5
  6. data/lib/htmlgrid/divcomposite.rb +1 -1
  7. data/lib/htmlgrid/dojotoolkit.rb +2 -6
  8. data/lib/htmlgrid/form.rb +1 -5
  9. data/lib/htmlgrid/grid.rb +9 -8
  10. data/lib/htmlgrid/link.rb +1 -1
  11. data/lib/htmlgrid/richtext.rb +1 -1
  12. data/lib/htmlgrid/spancomposite.rb +1 -1
  13. data/lib/htmlgrid/template.rb +1 -0
  14. data/lib/htmlgrid/ulcomposite.rb +1 -1
  15. data/lib/htmlgrid/version.rb +5 -0
  16. data/test/rebuild.rb +0 -0
  17. data/{ext/htmlgrid/extconf.rb → test/suite.rb} +10 -11
  18. data/test/test_add_row.rb +75 -0
  19. data/test/test_component.rb +7 -17
  20. data/test/test_composite.rb +33 -20
  21. data/test/test_datevalue.rb +2 -2
  22. data/test/test_form.rb +16 -15
  23. data/test/test_formlist.rb +11 -10
  24. data/test/test_grid.rb +10 -22
  25. data/test/test_input.rb +8 -7
  26. data/test/test_interaction_list.rb +257 -0
  27. data/test/test_label.rb +5 -14
  28. data/test/test_list.rb +3 -5
  29. data/test/test_select.rb +15 -8
  30. data/test/test_template.rb +15 -15
  31. data/test/test_text.rb +2 -2
  32. metadata +117 -74
  33. data/.gemtest +0 -0
  34. data/.gitignore +0 -3
  35. data/.travis.yml +0 -28
  36. data/COPYING +0 -515
  37. data/Gemfile +0 -20
  38. data/Gemfile.lock +0 -50
  39. data/README.txt +0 -31
  40. data/Rakefile +0 -52
  41. data/ext/htmlgrid/MANIFEST +0 -3
  42. data/ext/htmlgrid/grid.c +0 -899
  43. data/ext/htmlgrid/htmlgrid.c +0 -30
  44. data/ext/htmlgrid/include/grid.h +0 -79
  45. data/ext/htmlgrid/include/htmlgrid.h +0 -33
  46. data/htmlgrid.gemspec +0 -16
  47. data/install.rb +0 -1098
  48. data/usage-en.txt +0 -112
  49. data/widget/Tooltip.js +0 -85
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 493156bba6ea55bb67e136827debde748db5bbbe
4
+ data.tar.gz: 012b9c6ef18b01881c8529b9262d0599ef91d9d9
5
+ SHA512:
6
+ metadata.gz: 0efcf47d58cf047af2e6589845117f9afaf4c03e22e5eea79079538361ccb6a79a7821a0897cc458d469bb2de546feb374431626882e34550de18408e4121289
7
+ data.tar.gz: 4e00e05f74fda7af302fa339f1ca9d0f448463c2af6b5a25b54468f7f2998714d1787cc3ef2cf61542c1de63dac0909b921aa3c1a2b3f50e287b3e3f39de8414
data/History.txt CHANGED
@@ -1,6 +1,13 @@
1
+ === 1.0.8 / 10.05.2015
2
+
3
+ * Removed C-interface
4
+ * Removed obsolete tests for RUBY_VERSION < 1.9
5
+ * Ported to Ruby 2.3.0. Updated minitest. Use newer version of sbsm.
6
+ * Ruby 1.9.3 is no longer supported
7
+
1
8
  === 1.0.7 / 03.12.2013
2
9
 
3
- * Remove LEGACY_INTERFACE.
10
+ * Remove LEGACY_INTERFACE. No. LEGACY_INTERFACE was readded before release 1.0.7
4
11
  * Make travis work just fine.
5
12
 
6
13
  === 1.0.6 / 06.04.2012
data/Manifest.txt CHANGED
@@ -6,7 +6,7 @@ Gemfile.lock
6
6
  History.txt
7
7
  LICENCE.txt
8
8
  Manifest.txt
9
- README.txt
9
+ README.textile
10
10
  Rakefile
11
11
  ext/htmlgrid/MANIFEST
12
12
  ext/htmlgrid/extconf.rb
@@ -176,11 +176,7 @@ module HtmlGrid
176
176
  esc << if(entity = @@symbol_entities[byte])
177
177
  '&' << entity << ';'
178
178
  else
179
- if RUBY_VERSION >= '1.9'
180
- byte
181
- else
182
- byte.chr
183
- end
179
+ byte
184
180
  end
185
181
  }
186
182
  esc
@@ -218,18 +214,14 @@ module HtmlGrid
218
214
  @attributes.store('tabIndex', tab.to_s)
219
215
  end
220
216
  def to_html(context)
221
- if RUBY_VERSION > "1.9"
222
- _to_html(context, @value).to_s.force_encoding('utf-8')
223
- else
224
- _to_html(context, @value).to_s
225
- end
217
+ _to_html(context, @value).to_s.force_encoding('utf-8')
226
218
  end
227
219
  @@nl2br_ptrn = /(\r\n)|(\n)|(\r)/
228
220
  def _to_html(context, value=@value)
229
221
  if(value.is_a?(Array))
230
222
  value.collect { |item| _to_html(context, item) }.join(' ')
231
223
  elsif(value.respond_to?(:to_html))
232
- value.to_html(context).to_s
224
+ value.to_html(context).to_s.force_encoding('utf-8')
233
225
  else
234
226
  value.to_s.gsub(@@nl2br_ptrn, '<br>')
235
227
  end
@@ -42,6 +42,7 @@ end
42
42
  module HtmlGrid
43
43
  class AbstractComposite < Component
44
44
  LABELS = false
45
+ LEGACY_INTERFACE = true
45
46
  SYMBOL_MAP = {}
46
47
  CSS_MAP = {}
47
48
  CSS_ID_MAP = {}
@@ -61,6 +62,9 @@ module HtmlGrid
61
62
  elsif(component.is_a? Symbol)
62
63
  if(self.respond_to?(component, true))
63
64
  args = [model]
65
+ if(self::class::LEGACY_INTERFACE)
66
+ args.push(@session)
67
+ end
64
68
  self.send(component, *args)
65
69
  elsif(klass = symbol_map[component])
66
70
  klass.new(component, model, @session, self)
@@ -258,11 +262,7 @@ module HtmlGrid
258
262
  end
259
263
  def to_html(context)
260
264
  @grid.set_attributes(@attributes)
261
- if RUBY_VERSION > "1.9"
262
- super << @grid.to_html(context).force_encoding('utf-8')
263
- else
264
- super << @grid.to_html(context)
265
- end
265
+ super << @grid.to_html(context).force_encoding('utf-8')
266
266
  end
267
267
  private
268
268
  def back(model=@model, session=@session)
@@ -39,7 +39,7 @@ module HtmlGrid
39
39
  res << context.div(tag_attributes(idx)) {
40
40
  div.flatten.inject('') { |html, item|
41
41
  html << if(item.respond_to?(:to_html))
42
- item.to_html(context)
42
+ item.to_html(context).force_encoding('utf-8')
43
43
  else
44
44
  item.to_s
45
45
  end
@@ -71,7 +71,7 @@ module HtmlGrid
71
71
  html << context.div(attrs)
72
72
  elsif(@dojo_tooltip.respond_to?(:to_html))
73
73
  @dojo_tooltip.attributes.update(attrs)
74
- html << @dojo_tooltip.to_html(context)
74
+ html << @dojo_tooltip.to_html(context).force_encoding('utf-8')
75
75
  end
76
76
  unless(html.empty? || dojo_parse_widgets)
77
77
  html << context.script('type' => 'text/javascript') {
@@ -93,11 +93,7 @@ module HtmlGrid
93
93
  def dynamic_html_headers(context)
94
94
  headers = super
95
95
  encoding = self.class::DOJO_ENCODING
96
- encoding ||= if RUBY_VERSION >= '1.9'
97
- Encoding.default_external
98
- else
99
- $KCODE == 'UTF8' ? 'UTF-8' : 'ISO-8859-1'
100
- end
96
+ encoding ||= Encoding.default_external
101
97
  dojo_path = @lookandfeel.resource_global(:dojo_js)
102
98
  dojo_path ||= '/resources/dojo/dojo/dojo.js'
103
99
  args = { 'type' => 'text/javascript'}
data/lib/htmlgrid/form.rb CHANGED
@@ -30,11 +30,7 @@ require 'htmlgrid/submit'
30
30
  module HtmlGrid
31
31
  module FormMethods
32
32
  AUTOFILL = false
33
- if RUBY_VERSION >= '1.9'
34
- ACCEPT_CHARSET = Encoding.default_external || 'UTF-8'
35
- else
36
- ACCEPT_CHARSET = $KCODE == 'UTF8' ? 'UTF-8' : 'ISO-8859-1'
37
- end
33
+ ACCEPT_CHARSET = 'UTF-8'
38
34
  EVENT = nil
39
35
  FORM_ACTION = nil
40
36
  FORM_METHOD = 'POST'
data/lib/htmlgrid/grid.rb CHANGED
@@ -24,8 +24,9 @@
24
24
  #
25
25
  # HtmlGrid::Grid -- htmlgrid -- 23.02.2012 -- mhatakeyama@ywesee.com
26
26
  # HtmlGrid::Grid -- htmlgrid -- 12.01.2010 -- hwyss@ywesee.com
27
+ require 'htmlgrid/version'
27
28
  begin
28
- VERSION = '1.0.7'
29
+ VERSION = '1.0.8'
29
30
  begin
30
31
  # for gem install
31
32
  ext_dir = File.expand_path('../../ext/htmlgrid', File.dirname(__FILE__))
@@ -97,9 +98,9 @@ rescue LoadError
97
98
  end
98
99
  def component_html(cgi)
99
100
  html = ''
100
- @components.each { |component|
101
+ @components.each { |component|
101
102
  if component.respond_to? :to_html
102
- html << component.to_html(cgi).to_s
103
+ html << component.to_html(cgi).to_s.force_encoding('utf-8')
103
104
  else
104
105
  html << component.to_s
105
106
  end
@@ -196,7 +197,7 @@ rescue LoadError
196
197
  add_field(arg, x, y)
197
198
  elsif arg.kind_of? Array
198
199
  arg.each do |item|
199
- add_field(item, x, y)
200
+ add_field(item, x ? x : '', y)
200
201
  end
201
202
  else
202
203
  if(col)
@@ -215,7 +216,7 @@ rescue LoadError
215
216
  }
216
217
  end
217
218
  def add_background(x, y, w=1, h=1)
218
- each_field(x, y, w, h) { |field|
219
+ each_field(x, y, w, h) { |field|
219
220
  field.add_background(x, w)
220
221
  }
221
222
  end
@@ -254,7 +255,7 @@ rescue LoadError
254
255
  }
255
256
  end
256
257
  def each_field(x, y, w=1, h=1)
257
- y.upto([y+h, @height].min - 1) { |yy|
258
+ y.upto([y+h, @height].min - 1) { |yy|
258
259
  @rows[yy].each_field(x,w) { |field|
259
260
  yield(field)
260
261
  }
@@ -287,12 +288,12 @@ rescue LoadError
287
288
  # TODO
288
289
  # At the moment, offset value is not used
289
290
  # But probably offset value is used in grid.c
290
- initialize_grid(0, y+1)
291
+ initialize_grid(offset, y + 1)
291
292
  @rows[y].set_attributes(attr)
292
293
  end
293
294
  def to_html(cgi)
294
295
  cgi.table(@attributes) {
295
- @rows.collect { |row| row.to_html(cgi) }.join
296
+ @rows.collect { |row| row.to_html(cgi).force_encoding('utf-8') }.join
296
297
  }
297
298
  end
298
299
  def [](x, y)
data/lib/htmlgrid/link.rb CHANGED
@@ -44,7 +44,7 @@ module HtmlGrid
44
44
  def to_html(context)
45
45
  context.a(@attributes) {
46
46
  if(@value.respond_to?(:to_html))
47
- @value.to_html(context)
47
+ @value.to_html(context).force_encoding('utf-8')
48
48
  else
49
49
  super
50
50
  end
@@ -16,7 +16,7 @@ module HtmlGrid
16
16
  def to_html(context)
17
17
  @elements.collect { |element|
18
18
  if(element.respond_to?(:to_html))
19
- element.to_html(context)
19
+ element.to_html(context).force_encoding('utf-8')
20
20
  else
21
21
  element.to_s
22
22
  end
@@ -33,7 +33,7 @@ module HtmlGrid
33
33
  @grid.each_with_index { |span, idx|
34
34
  res << context.span(tag_attributes(idx)) {
35
35
  if(span.respond_to?(:to_html))
36
- span.to_html(context)
36
+ span.to_html(context).force_encoding('utf-8')
37
37
  else
38
38
  span
39
39
  end
@@ -32,6 +32,7 @@ module HtmlGrid
32
32
  FOOT = nil
33
33
  HEAD = nil
34
34
  META_TAGS = []
35
+ LEGACY_INTERFACE = true
35
36
  CSS_FILES = []
36
37
  JAVASCRIPTS = []
37
38
  def css_link(context, path=@lookandfeel.resource(:css))
@@ -35,7 +35,7 @@ module HtmlGrid
35
35
  @grid.each_with_index { |li, idx|
36
36
  inner_res << context.li(tag_attributes(idx)) {
37
37
  if(li.respond_to?(:to_html))
38
- li.to_html(context)
38
+ li.to_html(context).force_encoding('utf-8')
39
39
  else
40
40
  li
41
41
  end
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ module HtmlGrid
4
+ VERSION = '1.0.8'
5
+ end
data/test/rebuild.rb CHANGED
File without changes
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
3
  # HtmlGrid -- HyperTextMarkupLanguage Framework
4
- # Copyright (C) 2003 Hannes Wyss, ywesee - intellectual capital connected
4
+ # Copyright (C) 2003 ywesee - intellectual capital connected
5
+ # Andreas Schrafl, Benjamin Fay, Hannes Wyss, Markus Huggler
5
6
  #
6
7
  # This library is free software; you can redistribute it and/or
7
8
  # modify it under the terms of the GNU Lesser General Public
@@ -17,17 +18,15 @@
17
18
  # License along with this library; if not, write to the Free Software
18
19
  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20
  #
20
- # ywesee - intellectual capital connected
21
- # Winterthurerstrasse 52, CH-8006 Z�rich, Switzerland
22
- # hwyss@ywesee.com
21
+ # ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zuerich, Switzerland
22
+ # htmlgrid@ywesee.com, www.ywesee.com/htmlgrid
23
23
  #
24
- # extconf.rb -- htmlgrid -- 30.10.2003 -- hwyss@ywesee.com
24
+ # suite.rb -- htmlgrid -- 20.11.2002 -- hwyss@ywesee.com
25
25
 
26
- require 'mkmf'
26
+ $: << File.expand_path(File.dirname(__FILE__))
27
27
 
28
- if RUBY_VERSION >= '1.9'
29
- $CPPFLAGS += " -DRUBY_19"
30
- end
28
+ require 'rebuild'
31
29
 
32
- dir_config('htmlgrid', '.')
33
- create_makefile('htmlgrid')
30
+ Dir.foreach(File.dirname(__FILE__)) { |file|
31
+ require file if /^test_.*\.rb$/o.match(file)
32
+ }
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env ruby
2
+ #encoding: utf-8
3
+ $: << File.expand_path('../lib', File.dirname(__FILE__))
4
+ $: << File.dirname(__FILE__)
5
+
6
+ require 'minitest/autorun'
7
+ require 'stub/cgi'
8
+ require 'htmlgrid/composite'
9
+ require 'htmlgrid/inputtext'
10
+ require 'htmlgrid/form'
11
+
12
+ class StubComposite < HtmlGrid::Composite
13
+ attr_writer :container
14
+ COMPONENTS = {
15
+ [0,0,1] => :foo,
16
+ }
17
+ LABELS = true
18
+ SYMBOL_MAP = {
19
+ :bar => HtmlGrid::InputText,
20
+ }
21
+ attr_reader :model, :session
22
+ public :resolve_offset, :labels?
23
+ def init
24
+ @barcount=0
25
+ super
26
+ end
27
+ def foo(model)
28
+ 1.upto(2).each { |idx|
29
+ @grid.add(baz(model), 0, idx, 0)
30
+ }
31
+ "Foo"
32
+ end
33
+ def baz(model)
34
+ @barcount += 1
35
+ "Baz#{@barcount}"
36
+ end
37
+ end
38
+ class StubCompositeModel
39
+ end
40
+ class StubComposite2Model
41
+ end
42
+ class StubCompositeLookandfeel
43
+ def attributes(key)
44
+ {}
45
+ end
46
+ def lookup(key)
47
+ end
48
+ def base_url
49
+ 'http://www.oddb.org/de/gcc'
50
+ end
51
+ end
52
+ class StubCompositeSession
53
+ def lookandfeel
54
+ StubCompositeLookandfeel.new
55
+ end
56
+ def error(key)
57
+ end
58
+ end
59
+ class StubCompositeForm < HtmlGrid::Form
60
+ COMPONENTS = {
61
+ [0,0] => StubComposite
62
+ }
63
+ EVENT = :foo
64
+ end
65
+
66
+ class TestComposite < Minitest::Test
67
+ def setup
68
+ @composite = StubComposite.new([StubComposite2Model.new, StubCompositeModel.new],
69
+ StubCompositeSession.new)
70
+ end
71
+ def test_to_html
72
+ expected = '<TABLE cellspacing="0"><TR><TD>Foo</TD></TR><TR><TD>Baz1</TD></TR><TR><TD>Baz2</TD></TR></TABLE>'
73
+ assert_equal(expected, @composite.to_html(CGI.new))
74
+ end
75
+ end
@@ -26,7 +26,7 @@
26
26
  $: << File.expand_path("../lib", File.dirname(__FILE__))
27
27
  $: << File.expand_path("../ext", File.dirname(__FILE__))
28
28
 
29
- require 'test/unit'
29
+ require 'minitest/autorun'
30
30
  require 'htmlgrid/component'
31
31
 
32
32
  module HtmlGrid
@@ -35,7 +35,7 @@ module HtmlGrid
35
35
  end
36
36
  end
37
37
 
38
- class TestComponent < Test::Unit::TestCase
38
+ class TestComponent < Minitest::Test
39
39
  class StubAttributeComponent < HtmlGrid::Component
40
40
  HTML_ATTRIBUTES = { "key" => "val" }
41
41
  end
@@ -55,23 +55,17 @@ class TestComponent < Test::Unit::TestCase
55
55
  @component = HtmlGrid::Component.new(nil, nil)
56
56
  end
57
57
  def test_initialize1
58
- assert_nothing_raised {
59
- HtmlGrid::Component.new("foo", "bar")
60
- }
58
+ HtmlGrid::Component.new("foo", "bar")
61
59
  comp = HtmlGrid::Component.new("foo", "bar")
62
60
  assert_equal("foo", comp.model)
63
61
  assert_equal("bar", comp.session)
64
62
  assert_equal(nil, comp.container)
65
63
  assert_equal(false, comp.label?)
66
- assert_nothing_raised {
67
- comp.label = true
68
- }
64
+ comp.label = true
69
65
  assert_equal(true, comp.label?)
70
66
  end
71
67
  def test_initialize2
72
- assert_nothing_raised {
73
- HtmlGrid::Component.new("foo", "bar", "baz")
74
- }
68
+ HtmlGrid::Component.new("foo", "bar", "baz")
75
69
  comp = HtmlGrid::Component.new("foo", "bar", "baz")
76
70
  assert_equal("foo", comp.model)
77
71
  assert_equal("bar", comp.session)
@@ -83,17 +77,13 @@ class TestComponent < Test::Unit::TestCase
83
77
  assert_respond_to(comp, :attributes)
84
78
  assert_equal(expected, comp.attributes)
85
79
  assert_equal(expected, StubAttributeComponent::HTML_ATTRIBUTES)
86
- assert_nothing_raised {
87
- comp.attributes.store("other", "val")
88
- }
80
+ comp.attributes.store("other", "val")
89
81
  expected2 = { "key" => "val", "other" => "val" }
90
82
  assert_equal(expected2, comp.attributes)
91
83
  assert_equal(expected, StubAttributeComponent::HTML_ATTRIBUTES)
92
84
  assert_equal({}, @component.attributes)
93
85
  assert_equal({}, HtmlGrid::Component::HTML_ATTRIBUTES)
94
- assert_nothing_raised {
95
- @component.attributes.store("third", "val")
96
- }
86
+ @component.attributes.store("third", "val")
97
87
  expected = {"third"=>"val"}
98
88
  assert_equal(expected, @component.attributes)
99
89
  assert_equal({}, HtmlGrid::Component::HTML_ATTRIBUTES)
@@ -26,11 +26,12 @@
26
26
  $: << File.expand_path('../lib', File.dirname(__FILE__))
27
27
  $: << File.dirname(__FILE__)
28
28
 
29
- require 'test/unit'
29
+ require 'minitest/autorun'
30
30
  require 'stub/cgi'
31
31
  require 'htmlgrid/composite'
32
32
  require 'htmlgrid/inputtext'
33
33
  require 'htmlgrid/form'
34
+ require 'htmlgrid/button'
34
35
 
35
36
  class StubComposite < HtmlGrid::Composite
36
37
  attr_writer :container
@@ -51,13 +52,16 @@ class StubComposite < HtmlGrid::Composite
51
52
  @barcount=0
52
53
  super
53
54
  end
54
- def foo(model)
55
+ def foo(model, lookandfeel)
55
56
  "Foo"
56
57
  end
57
- def baz(model)
58
+ def baz(model, lookandfeel)
58
59
  @barcount += 1
59
60
  "Baz#{@barcount}"
60
61
  end
62
+ def back
63
+ super
64
+ end
61
65
  end
62
66
  class StubCompositeComponent < HtmlGrid::Component
63
67
  def to_html(context)
@@ -84,6 +88,9 @@ end
84
88
  class StubCompositeModel
85
89
  end
86
90
  class StubCompositeLookandfeel
91
+ def event_url(one)
92
+ return 'event_url'
93
+ end
87
94
  def attributes(key)
88
95
  {}
89
96
  end
@@ -127,42 +134,38 @@ class StubCompositeColspan4 < HtmlGrid::Composite
127
134
  }
128
135
  end
129
136
 
130
- class TestComposite < Test::Unit::TestCase
137
+ class TestComposite < Minitest::Test
131
138
  def setup
132
139
  @composite = StubComposite.new(StubCompositeModel.new, StubCompositeSession.new)
133
140
  end
134
141
  def test_create_method
135
142
  foo = nil
136
- assert_nothing_raised {
137
- foo = @composite.create(:foo, @composite.model)
138
- }
143
+ foo = @composite.create(:foo, @composite.model)
139
144
  assert_equal("Foo", foo)
140
145
  end
141
146
  def test_create_symbol
142
147
  bar = nil
143
- assert_nothing_raised {
144
- bar = @composite.create(:bar, @composite.model)
145
- }
148
+ bar = @composite.create(:bar, @composite.model)
146
149
  assert_equal(HtmlGrid::InputText, bar.class)
147
150
  end
148
151
  def test_full_colspan1
149
152
  composite = StubCompositeColspan1.new(StubCompositeModel.new, StubCompositeSession.new)
150
- assert_nothing_raised { composite.full_colspan }
153
+ composite.full_colspan
151
154
  assert_equal(nil, composite.full_colspan)
152
155
  end
153
156
  def test_full_colspan2
154
157
  composite = StubCompositeColspan2.new(StubCompositeModel.new, StubCompositeSession.new)
155
- assert_nothing_raised { composite.full_colspan }
158
+ composite.full_colspan
156
159
  assert_equal(nil, composite.full_colspan)
157
160
  end
158
161
  def test_full_colspan3
159
162
  composite = StubCompositeColspan3.new(StubCompositeModel.new, StubCompositeSession.new)
160
- assert_nothing_raised { composite.full_colspan }
163
+ composite.full_colspan
161
164
  assert_equal(2, composite.full_colspan)
162
165
  end
163
166
  def test_full_colspan4
164
167
  composite = StubCompositeColspan4.new(StubCompositeModel.new, StubCompositeSession.new)
165
- assert_nothing_raised { composite.full_colspan }
168
+ composite.full_colspan
166
169
  assert_equal(3, composite.full_colspan)
167
170
  end
168
171
  def test_labels1
@@ -172,10 +175,10 @@ class TestComposite < Test::Unit::TestCase
172
175
  def test_labels2
173
176
  assert_equal(true, @composite.labels?)
174
177
  end
175
- def test_to_html
176
- expected = '<TABLE cellspacing="0"><TR><TD>Baz1FooBaz2</TD></TR><TR><TD>Baz3Baz4</TD></TR></TABLE>'
177
- assert_equal(expected, @composite.to_html(CGI.new))
178
- end
178
+ def test_to_html
179
+ expected = '<TABLE cellspacing="0"><TR><TD>Baz1FooBaz2</TD></TR><TR><TD>Baz3Baz4</TD></TR></TABLE>'
180
+ assert_equal(expected, @composite.to_html(CGI.new))
181
+ end
179
182
  def test_resolve_offset
180
183
  matrix = [1,2,3,4]
181
184
  assert_equal(matrix, @composite.resolve_offset(matrix))
@@ -184,7 +187,7 @@ class TestComposite < Test::Unit::TestCase
184
187
  assert_equal(expected, @composite.resolve_offset(matrix, offset))
185
188
  end
186
189
  def test_event
187
- assert_nothing_raised { @composite.event() }
190
+ @composite.event()
188
191
  form = StubCompositeForm.new(@composite.model, @composite.session)
189
192
  @composite.container = form
190
193
  assert_equal(:foo, @composite.event())
@@ -197,5 +200,15 @@ class TestComposite < Test::Unit::TestCase
197
200
  expected = '<TABLE cellspacing="0"><TR><TD><A class="standard">brafoo</A></TD></TR></TABLE>'
198
201
  assert_equal(expected, composite.to_html(CGI.new))
199
202
  composite = StubComposite4.new(StubCompositeModel.new, StubCompositeSession.new)
200
- end
203
+ end
204
+ def test_to_back
205
+ if RUBY_VERSION.split(".").first.eql?('1')
206
+ expected = "<INPUT type=\"button\" name=\"back\" onClick=\"document.location.href='event_url';\">"
207
+ else
208
+ # It looks like Ruby 2.x escapes the ' which is not strictly necessary
209
+ expected = "<INPUT type=\"button\" name=\"back\" onClick=\"document.location.href=&#39;event_url&#39;;\">"
210
+ end
211
+ html = @composite.back().to_html(CGI.new)
212
+ assert_equal(expected, html)
213
+ end
201
214
  end
@@ -25,7 +25,7 @@
25
25
 
26
26
  $: << File.expand_path("../lib", File.dirname(__FILE__))
27
27
 
28
- require 'test/unit'
28
+ require 'minitest/autorun'
29
29
  require 'htmlgrid/datevalue'
30
30
  require 'stub/cgi'
31
31
  require 'date'
@@ -49,7 +49,7 @@ class StubDateProvider
49
49
  end
50
50
  end
51
51
 
52
- class TestDateValue < Test::Unit::TestCase
52
+ class TestDateValue < Minitest::Test
53
53
  def setup
54
54
  @component = HtmlGrid::DateValue.new(:date, StubDateProvider.new,
55
55
  StubDateSession.new)
data/test/test_form.rb CHANGED
@@ -26,7 +26,7 @@
26
26
  $: << File.dirname(__FILE__)
27
27
  $: << File.expand_path("../lib", File.dirname(__FILE__))
28
28
 
29
- require 'test/unit'
29
+ require 'minitest/autorun'
30
30
  require 'htmlgrid/form'
31
31
  require 'stub/cgi'
32
32
 
@@ -76,7 +76,7 @@ class StubFormMultiPart < HtmlGrid::Form
76
76
  TAG_METHOD = :multipart_form
77
77
  end
78
78
 
79
- class TestForm < Test::Unit::TestCase
79
+ class TestForm < Minitest::Test
80
80
  def setup
81
81
  @model = StubFormModel.new
82
82
  @lookandfeel = StubFormLookandfeel.new
@@ -88,24 +88,25 @@ class TestForm < Test::Unit::TestCase
88
88
  def test_multipart
89
89
  form = StubFormMultiPart.new(@model, @lookandfeel)
90
90
  result = form.to_html(CGI.new)
91
- expected = '<FORM NAME="stdform" METHOD="POST" ACTION="http://test.oddb.org/de/gcc" ACCEPT-CHARSET="UTF-8" ENCTYPE="multipart/form-data">'
92
- assert_equal(0, result.index(expected), "expected\n#{result}\nto start with\n#{expected}")
91
+ expected = '<FORM NAME="stdform" METHOD="POST" ACTION="http://test.oddb.org/de/gcc" ACCEPT-CHARSET="UTF-8" ENCTYPE="multipart/form-data">'
92
+ assert_equal(0, result.index(expected), "expected\n#{result}\nto start with\n#{expected}")
93
93
  end
94
94
  def test_to_html
95
95
  result = @form.to_html(CGI.new)
96
- expected = [
97
- '<INPUT TYPE="hidden" NAME="flavor" VALUE="gcc">',
98
- '<INPUT TYPE="hidden" NAME="language" VALUE="de">',
99
- '<INPUT NAME="event" ID="event" VALUE="foo" TYPE="hidden">',
100
- '<INPUT TYPE="hidden" NAME="state_id" VALUE="1">',
101
- ]
102
- expected.each { |line|
103
- assert(result.index(line), "\nmissing #{line}\n in #{result}")
96
+ expected = [
97
+ '<INPUT TYPE="hidden" NAME="flavor" VALUE="gcc">',
98
+ '<INPUT TYPE="hidden" NAME="language" VALUE="de">',
99
+ '<INPUT NAME="event" ID="event" VALUE="foo" TYPE="hidden">',
100
+ '<INPUT TYPE="hidden" NAME="state_id" VALUE="1">',
101
+ ]
102
+ expected.each_with_index { |line, idx|
103
+ assert(result.index(line), "#{idx}: missing #{line}\n in #{result}")
104
104
  }
105
105
  end
106
106
  def test_submit
107
- expected = '<INPUT value="Submit-Value" type="submit" name="foo">'
108
- assert_equal(expected, @form.submit(@model, @lookandfeel).to_html(CGI.new))
107
+ html = @form.submit(@model, @lookandfeel).to_html(CGI.new)
108
+ expected = '<INPUT value="Submit-Value" type="submit" name="foo">'
109
+ assert_equal(expected, html)
109
110
  end
110
111
  def test_onsubmit
111
112
  @form.onsubmit = 'submitted'
@@ -115,7 +116,7 @@ class TestForm < Test::Unit::TestCase
115
116
  end
116
117
  def test_onsubmit_init
117
118
  form = nil
118
- assert_nothing_raised { form = StubForm2.new(@model, @lookandfeel) }
119
+ form = StubForm2.new(@model, @lookandfeel)
119
120
  expected = 'onSubmit="submitted"'
120
121
  result = /<FORM[^>]+>/.match(form.to_html(CGI.new))[0]
121
122
  assert(result.index(expected), "missing:\n#{expected}\nin:\n#{result}")