sbsm 1.2.6 → 1.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,9 +21,8 @@
21
21
  # ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zürich, Switzerland
22
22
  # hwyss@ywesee.com
23
23
  #
24
- # TestLookandfeel -- sbsm -- 15.11.2002 -- hwyss@ywesee.com
25
-
26
- require 'test/unit'
24
+ # TestLookandfeel -- sbsm -- 15.11.2002 -- hwyss@ywesee.com
25
+ require 'minitest/autorun'
27
26
  require 'sbsm/lookandfeel'
28
27
  require 'date'
29
28
  require 'sbsm/lookandfeelwrapper'
@@ -35,11 +34,12 @@ class StubLookandfeelState
35
34
  end
36
35
  end
37
36
  class StubLookandfeelSession
38
- attr_accessor :persistent_user_input, :user_input, :state,
37
+ attr_accessor :persistent_user_input, :user_input, :state,
39
38
  :is_crawler
40
39
  DEFAULT_LANGUAGE = "de"
41
40
  def initialize(*args)
42
- @persistent_user_input = {}
41
+ @persistent_user_input = {}
42
+ @is_crawler = nil
43
43
  @user_input = nil
44
44
  end
45
45
  def default_language
@@ -54,8 +54,8 @@ class StubLookandfeelSession
54
54
  end
55
55
  def navigation
56
56
  [
57
- StubLookandfeelState.new(:foo),
58
- StubLookandfeelState.new(:bar),
57
+ StubLookandfeelState.new(:foo),
58
+ StubLookandfeelState.new(:bar),
59
59
  StubLookandfeelState.new(:baz),
60
60
  ]
61
61
  end
@@ -114,7 +114,7 @@ class LookandfeelWrapper2 < SBSM::LookandfeelWrapper
114
114
  ENABLED = [:baz]
115
115
  end
116
116
 
117
- class TestLookandfeel < Test::Unit::TestCase
117
+ class TestLookandfeel < Minitest::Test
118
118
  def setup
119
119
  @session = StubLookandfeelSession.new
120
120
  @lookandfeel = LookandfeelBase.new(@session)
@@ -164,17 +164,15 @@ class TestLookandfeel < Test::Unit::TestCase
164
164
  assert_equal("http://test.com/de/gcc", @lookandfeel.base_url)
165
165
  end
166
166
  def test_event_url
167
- # state_id is 4, because @session.state = nil
168
- assert_equal("http://test.com/de/gcc/foo/state_id/4/bar/baz",
169
- @lookandfeel.event_url(:foo, {:bar => 'baz'}))
167
+ assert_match(/http:\/\/test.com\/de\/gcc\/foo\/state_id\/\d\/bar\/baz/,@lookandfeel.event_url(:foo, {:bar => 'baz'}))
170
168
  end
171
169
  def test_event_url__crawler
172
170
  @session.is_crawler = true
173
- assert_equal("http://test.com/de/gcc/foo/bar/baz",
171
+ assert_equal("http://test.com/de/gcc/foo/bar/baz",
174
172
  @lookandfeel.event_url(:foo, {:bar => 'baz'}))
175
173
  end
176
174
  def test_event_url__state_id_given
177
- assert_equal("http://test.com/de/gcc/foo/bar/baz/state_id/mine",
175
+ assert_equal("http://test.com/de/gcc/foo/bar/baz/state_id/mine",
178
176
  @lookandfeel.event_url(:foo, [:bar, 'baz', :state_id, 'mine']))
179
177
  end
180
178
  def test_format_price
@@ -191,7 +189,7 @@ class TestLookandfeel < Test::Unit::TestCase
191
189
  assert_equal(['de', 'fr'], @lookandfeel.languages)
192
190
  end
193
191
  end
194
- class TestLookandfeelWrapper < Test::Unit::TestCase
192
+ class TestLookandfeelWrapper < Minitest::Test
195
193
  def setup
196
194
  @lookandfeel = LookandfeelBase.new(StubLookandfeelSession.new)
197
195
  @wrapped = LookandfeelWrapper1.new(@lookandfeel)
@@ -212,7 +210,7 @@ class TestLookandfeelWrapper < Test::Unit::TestCase
212
210
  assert_equal([:foo, :bar, :baz], result)
213
211
  end
214
212
  def test_flavor
215
- assert_equal('gcc', @wrapped.flavor)
213
+ assert_equal('gcc', @wrapped.flavor)
216
214
  end
217
215
  def test_resource1
218
216
  lnf = SBSM::LookandfeelWrapper.new(@lookandfeel)
data/test/test_session.rb CHANGED
@@ -23,7 +23,7 @@
23
23
  #
24
24
  # TestSession -- sbsm -- 22.10.2002 -- hwyss@ywesee.com
25
25
 
26
- require 'test/unit'
26
+ require 'minitest/autorun'
27
27
  require 'sbsm/session'
28
28
  #require 'htmlgrid/component'
29
29
 
@@ -130,7 +130,7 @@ class StubSessionSession < SBSM::Session
130
130
  end
131
131
  end
132
132
 
133
- class TestSession < Test::Unit::TestCase
133
+ class TestSession < Minitest::Test
134
134
  def setup
135
135
  @session = Session.new("test", StubSessionApp.new, StubSessionValidator.new)
136
136
  @request = StubSessionRequest.new
@@ -154,13 +154,13 @@ class TestSession < Test::Unit::TestCase
154
154
  req2["event"] = "foo"
155
155
  @session.process(req2)
156
156
  state2 = @session.state
157
- assert_not_equal(state1, state2)
157
+ refute_equal(state1, state2)
158
158
  req3 = StubSessionRequest.new
159
159
  req3["event"] = :bar
160
160
  @session.process(req3)
161
161
  state3 = @session.state
162
- assert_not_equal(state1, state3)
163
- assert_not_equal(state2, state3)
162
+ refute_equal(state1, state3)
163
+ refute_equal(state2, state3)
164
164
  attended = {
165
165
  state1.object_id => state1,
166
166
  state2.object_id => state2,
@@ -172,9 +172,9 @@ class TestSession < Test::Unit::TestCase
172
172
  @session.process(req4)
173
173
  @session.cap_max_states
174
174
  state4 = @session.state
175
- assert_not_equal(state1, state4)
176
- assert_not_equal(state2, state4)
177
- assert_not_equal(state3, state4)
175
+ refute_equal(state1, state4)
176
+ refute_equal(state2, state4)
177
+ refute_equal(state3, state4)
178
178
  attended = {
179
179
  state2.object_id => state2,
180
180
  state3.object_id => state3,
data/test/test_state.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 'sbsm/state'
31
31
 
32
32
  class StubStateState1
@@ -98,7 +98,7 @@ class UserState < State
98
98
  }
99
99
  end
100
100
 
101
- class TestState < Test::Unit::TestCase
101
+ class TestState < Minitest::Test
102
102
  def setup
103
103
  @state = State.new(nil, nil)
104
104
  end
@@ -152,7 +152,7 @@ class TestState < Test::Unit::TestCase
152
152
  assert_equal(2, @state.warnings.size)
153
153
  end
154
154
  end
155
- class TestUserState < Test::Unit::TestCase
155
+ class TestUserState < Minitest::Test
156
156
  def test_no_user_view_defined
157
157
  state = State.new(StubStateSession.new, nil)
158
158
  assert_equal(StubStateView, state.view.class)
@@ -5,7 +5,7 @@
5
5
  $: << File.dirname(__FILE__)
6
6
  $:.unshift File.expand_path('../lib', File.dirname(__FILE__))
7
7
 
8
- require 'test/unit'
8
+ require 'minitest/autorun'
9
9
  require 'sbsm/trans_handler'
10
10
  require 'cgi'
11
11
  require 'fileutils'
@@ -14,7 +14,7 @@ module Apache
14
14
  DECLINED = 0
15
15
  end
16
16
  module SBSM
17
- class TestTransHandler < Test::Unit::TestCase
17
+ class TestTransHandler < Minitest::Test
18
18
  class RequestStub
19
19
  attr_accessor :uri, :notes, :server
20
20
  end
@@ -39,11 +39,6 @@ module SBSM
39
39
  end
40
40
  def test_parser_name
41
41
  assert_equal('uri', TransHandler.instance.parser_name)
42
- assert_equal('flavored_uri',
43
- FlavoredTransHandler.instance.parser_name)
44
- omit("We are unable to load rockit. Do we need it really?")
45
- assert_not_equal(TransHandler.instance.uri_parser,
46
- FlavoredTransHandler.instance.uri_parser)
47
42
  end
48
43
  def test_translate_uri
49
44
  request = RequestStub.new
@@ -128,9 +123,7 @@ module SBSM
128
123
 
129
124
  request.uri = '/shortcut'
130
125
  request.notes = NotesStub.new
131
- assert_nothing_raised {
132
- TransHandler.instance.translate_uri(request)
133
- }
126
+ TransHandler.instance.translate_uri(request)
134
127
  assert_equal({}, request.notes)
135
128
  assert_equal('/shortcut', request.uri)
136
129
 
@@ -150,13 +143,11 @@ shortcut:
150
143
 
151
144
  request.uri = '/shortcut'
152
145
  request.notes = NotesStub.new
153
- assert_nothing_raised {
154
146
  # run in safe-mode
155
147
  Thread.new {
156
148
  $SAFE = 1
157
149
  TransHandler.instance.translate_uri(request)
158
150
  }.join
159
- }
160
151
  assert_equal({'shortcut' => 'variables'}, request.notes)
161
152
  assert_equal('/index.rbx', request.uri)
162
153
 
@@ -171,7 +162,7 @@ shortcut:
171
162
  assert_equal('/index.rbx', request.uri)
172
163
  end
173
164
  end
174
- class TestFlavoredTransHandler < Test::Unit::TestCase
165
+ class TestTransHandler < Minitest::Test
175
166
  class RequestStub
176
167
  attr_accessor :uri, :notes, :server
177
168
  end
@@ -200,25 +191,25 @@ shortcut:
200
191
 
201
192
  request.uri = '/'
202
193
  request.notes = NotesStub.new
203
- FlavoredTransHandler.instance.translate_uri(request)
194
+ TransHandler.instance.translate_uri(request)
204
195
  assert_equal({}, request.notes)
205
196
  assert_equal('/index.rbx', request.uri)
206
197
 
207
198
  request.uri = '/fr'
208
199
  request.notes = NotesStub.new
209
- FlavoredTransHandler.instance.translate_uri(request)
200
+ TransHandler.instance.translate_uri(request)
210
201
  assert_equal({'language' => 'fr'}, request.notes)
211
202
  assert_equal('/index.rbx', request.uri)
212
203
 
213
204
  request.uri = '/en/'
214
205
  request.notes = NotesStub.new
215
- FlavoredTransHandler.instance.translate_uri(request)
206
+ TransHandler.instance.translate_uri(request)
216
207
  assert_equal({'language' => 'en'}, request.notes)
217
208
  assert_equal('/index.rbx', request.uri)
218
209
 
219
210
  request.uri = '/en/flavor'
220
211
  request.notes = NotesStub.new
221
- FlavoredTransHandler.instance.translate_uri(request)
212
+ TransHandler.instance.translate_uri(request)
222
213
  expected = {
223
214
  'language'=> 'en',
224
215
  'flavor' => 'flavor',
@@ -228,7 +219,7 @@ shortcut:
228
219
 
229
220
  request.uri = '/en/other'
230
221
  request.notes = NotesStub.new
231
- FlavoredTransHandler.instance.translate_uri(request)
222
+ TransHandler.instance.translate_uri(request)
232
223
  expected = {
233
224
  'language'=> 'en',
234
225
  'flavor' => 'other',
@@ -238,7 +229,7 @@ shortcut:
238
229
 
239
230
  request.uri = '/de/gcc/search/state_id/407422388/search_query/ponstan'
240
231
  request.notes = NotesStub.new
241
- FlavoredTransHandler.instance.translate_uri(request)
232
+ TransHandler.instance.translate_uri(request)
242
233
  expected = {
243
234
  'language' => 'de',
244
235
  'flavor' => 'gcc',
@@ -251,7 +242,7 @@ shortcut:
251
242
 
252
243
  request.uri = '/de/gcc/search/state_id/407422388/search_query/ponstan/page/4'
253
244
  request.notes = NotesStub.new
254
- FlavoredTransHandler.instance.translate_uri(request)
245
+ TransHandler.instance.translate_uri(request)
255
246
  expected = {
256
247
  'language' => 'de',
257
248
  'flavor' => 'gcc',
@@ -266,7 +257,7 @@ shortcut:
266
257
  request.uri = '/de/gcc/search/pretty//state_id/407422388/search_query/ponstan/page/4'
267
258
  request.notes = NotesStub.new
268
259
  expected = '/index.rbx?language=de&flavor=gcc&event=search&pretty=&state_id=407422388&search_query=ponstan&page=4'
269
- FlavoredTransHandler.instance.translate_uri(request)
260
+ TransHandler.instance.translate_uri(request)
270
261
  expected = {
271
262
  'language' => 'de',
272
263
  'flavor' => 'gcc',
@@ -281,7 +272,7 @@ shortcut:
281
272
 
282
273
  request.uri = '/de/gcc/search/search_query/'
283
274
  request.notes = NotesStub.new
284
- FlavoredTransHandler.instance.translate_uri(request)
275
+ TransHandler.instance.translate_uri(request)
285
276
  expected = {
286
277
  'language' => 'de',
287
278
  'flavor' => 'gcc',
@@ -298,12 +289,10 @@ shortcut:
298
289
 
299
290
  request.uri = '/shortcut'
300
291
  request.notes = NotesStub.new
301
- assert_nothing_raised {
302
- FlavoredTransHandler.instance.translate_uri(request)
303
- }
292
+ TransHandler.instance.translate_uri(request)
304
293
  assert_equal({}, request.notes)
305
294
  assert_equal('/shortcut', request.uri)
306
-
295
+
307
296
  FileUtils.mkdir_p(@etc_path)
308
297
  shortcut = File.join(@etc_path, 'trans_handler.yml')
309
298
  File.open(shortcut, 'w') { |fh|
@@ -320,19 +309,17 @@ shortcut:
320
309
 
321
310
  request.uri = '/shortcut'
322
311
  request.notes = NotesStub.new
323
- assert_nothing_raised {
324
312
  # run in safe-mode
325
313
  Thread.new {
326
314
  $SAFE = 1
327
- FlavoredTransHandler.instance.translate_uri(request)
315
+ TransHandler.instance.translate_uri(request)
328
316
  }.join
329
- }
330
317
  assert_equal({'shortcut' => 'variables'}, request.notes)
331
318
  assert_equal('/index.rbx', request.uri)
332
319
 
333
320
  request.uri = '/somewhere'
334
321
  request.notes = NotesStub.new
335
- FlavoredTransHandler.instance.translate_uri(request)
322
+ TransHandler.instance.translate_uri(request)
336
323
  expected = {
337
324
  'over' => 'the rainbow',
338
325
  'goodbye' => 'yellow brick road',
@@ -341,7 +328,7 @@ shortcut:
341
328
  assert_equal('/index.rbx', request.uri)
342
329
  end
343
330
  end
344
- class TestZoneTransHandler < Test::Unit::TestCase
331
+ class TestTransHandler < Minitest::Test
345
332
  class RequestStub
346
333
  attr_accessor :uri, :notes, :server
347
334
  end
@@ -370,25 +357,25 @@ shortcut:
370
357
 
371
358
  request.uri = '/'
372
359
  request.notes = NotesStub.new
373
- ZoneTransHandler.instance.translate_uri(request)
360
+ TransHandler.instance.translate_uri(request)
374
361
  assert_equal({}, request.notes)
375
362
  assert_equal('/index.rbx', request.uri)
376
363
 
377
364
  request.uri = '/fr'
378
365
  request.notes = NotesStub.new
379
- ZoneTransHandler.instance.translate_uri(request)
366
+ TransHandler.instance.translate_uri(request)
380
367
  assert_equal({'language' => 'fr'}, request.notes)
381
368
  assert_equal('/index.rbx', request.uri)
382
369
 
383
370
  request.uri = '/en/'
384
371
  request.notes = NotesStub.new
385
- ZoneTransHandler.instance.translate_uri(request)
372
+ TransHandler.instance.translate_uri(request)
386
373
  assert_equal({'language' => 'en'}, request.notes)
387
374
  assert_equal('/index.rbx', request.uri)
388
375
 
389
376
  request.uri = '/en/zone'
390
377
  request.notes = NotesStub.new
391
- ZoneTransHandler.instance.translate_uri(request)
378
+ TransHandler.instance.translate_uri(request)
392
379
  expected = {
393
380
  'language'=> 'en',
394
381
  'flavor' => 'zone',
@@ -398,7 +385,7 @@ shortcut:
398
385
 
399
386
  request.uri = '/en/other'
400
387
  request.notes = NotesStub.new
401
- ZoneTransHandler.instance.translate_uri(request)
388
+ TransHandler.instance.translate_uri(request)
402
389
  expected = {
403
390
  'language'=> 'en',
404
391
  'flavor' => 'other',
@@ -408,7 +395,7 @@ shortcut:
408
395
 
409
396
  request.uri = '/de/gcc/search/state_id/407422388/search_query/ponstan/page/4'
410
397
  request.notes = NotesStub.new
411
- ZoneTransHandler.instance.translate_uri(request)
398
+ TransHandler.instance.translate_uri(request)
412
399
  expected = {
413
400
  'language' => 'de',
414
401
  'flavor' => 'gcc',
@@ -423,7 +410,7 @@ shortcut:
423
410
  request.uri = '/de/gcc/search/pretty//state_id/407422388/search_query/ponstan/page/4'
424
411
  request.notes = NotesStub.new
425
412
  expected = '/index.rbx?language=de&zone=gcc&event=search&detail=objid&pretty=&state_id=407422388&search_query=ponstan&page=4'
426
- ZoneTransHandler.instance.translate_uri(request)
413
+ TransHandler.instance.translate_uri(request)
427
414
  expected = {
428
415
  'language' => 'de',
429
416
  'flavor' => 'gcc',
@@ -438,7 +425,7 @@ shortcut:
438
425
 
439
426
  request.uri = '/de/gcc/search/search_query/'
440
427
  request.notes = NotesStub.new
441
- ZoneTransHandler.instance.translate_uri(request)
428
+ TransHandler.instance.translate_uri(request)
442
429
  expected = {
443
430
  'language' => 'de',
444
431
  'flavor' => 'gcc',
data/test/test_user.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 'sbsm/user'
31
31
  require 'sbsm/state'
32
32
 
@@ -35,7 +35,7 @@ class User < SBSM::User
35
35
  NAVIGATION = [StubUserState]
36
36
  end
37
37
 
38
- class TestUser < Test::Unit::TestCase
38
+ class TestUser < Minitest::Test
39
39
  def setup
40
40
  @user = User.new
41
41
  end
@@ -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 'sbsm/validator'
31
31
 
32
32
  class Validator < SBSM::Validator
@@ -48,20 +48,18 @@ class Validator < SBSM::Validator
48
48
  HTML = [ :html ]
49
49
  end
50
50
 
51
- class TestValidator < Test::Unit::TestCase
51
+ class TestValidator < Minitest::Test
52
52
  def setup
53
53
  @val = Validator.new
54
54
  end
55
55
  def test_reset_errors
56
56
  assert_equal({}, @val.errors)
57
57
  @val.errors = {:foo=>:bar}
58
- assert_nothing_raised {
59
- @val.reset_errors
60
- }
58
+ @val.reset_errors
61
59
  assert_equal({}, @val.errors)
62
60
  end
63
61
  def test_validate
64
- assert_nothing_raised { @val.validate(:something, :other) }
62
+ assert_equal(nil, @val.validate(:something, :other) )
65
63
  end
66
64
  def test_boolean
67
65
  assert_equal(true, @val.validate(:bool, 'true'))