Class: TestLanguage

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
test/test_util/language.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



21
22
23
24
# File 'test/test_util/language.rb', line 21

def setup
  Language.reset_oid
  @obj = Language.new
end

- (Object) test_has_description



94
95
96
97
98
99
100
101
# File 'test/test_util/language.rb', line 94

def test_has_description
  values = {
    'de' => 'eine Beschreibung'
  }
  @obj.update_values(values)
  assert_equal(true, @obj.has_description?('eine Beschreibung'))  
  assert_equal(false, @obj.has_description?('eine andere Beschreibung'))
end

- (Object) test_init



102
103
104
105
106
107
108
109
110
111
# File 'test/test_util/language.rb', line 102

def test_init
  pointer = ODDB::Persistence::Pointer.new([:foo, 1], [:bar])
  @obj.pointer = pointer
  @obj.init(nil)
  expected = pointer.parent + [:bar, @obj.oid]
  assert_equal(expected, @obj.pointer)
  @obj.init(nil)
  expected = pointer.parent + [:bar, @obj.oid]
  assert_equal(expected, @obj.pointer)
end

- (Object) test_method_missing



82
83
84
85
86
87
88
# File 'test/test_util/language.rb', line 82

def test_method_missing
  @obj.descriptions.store("de","eine Beschreibung")
  assert_nothing_raised { @obj.de }
  assert_nothing_raised { @obj.description('de') }
  assert_equal('eine Beschreibung', @obj.de)
  assert_equal('eine Beschreibung', @obj.description('de'))
end

- (Object) test_respond_to



89
90
91
92
93
# File 'test/test_util/language.rb', line 89

def test_respond_to
  @obj.descriptions.store("de","eine Beschreibung")
  assert_respond_to(@obj, :de)
  assert_respond_to(@obj, :fr)
end

- (Object) test_update_values1



25
26
27
28
29
30
31
# File 'test/test_util/language.rb', line 25

def  test_update_values1
  values = {
    'de' => 'eine Beschreibung'
  }
  @obj.update_values(values)
  assert_equal(values, @obj.descriptions.to_hash)
end

- (Object) test_update_values2



32
33
34
35
36
37
38
39
40
# File 'test/test_util/language.rb', line 32

def test_update_values2
  @obj.descriptions.store("de","eine Beschreibung")
  assert_equal({'de' => 'eine Beschreibung'}, @obj.descriptions.to_hash)
  values = {
    'de' => "eine andere Beschreibung"
  }
  @obj.update_values(values)
  assert_equal(values, @obj.descriptions.to_hash)
end

- (Object) test_update_values3



41
42
43
44
45
46
47
48
49
50
51
# File 'test/test_util/language.rb', line 41

def test_update_values3
  @obj.foo = 'bar'
  @obj.descriptions.store("de","eine Beschreibung")
  values = {
    'de' =>  "eine andere Beschreibung",
    :foo =>  "baz",
  }
  @obj.update_values(values)
  assert_equal({'de'  => 'eine andere Beschreibung'}, @obj.descriptions.to_hash)
  assert_equal('baz', @obj.foo)
end

- (Object) test_update_values_default_value



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'test/test_util/language.rb', line 52

def test_update_values_default_value
  values = {
    'de' =>  'eine Beschreibung',
  }
  @obj.update_values(values)
  assert_equal('eine Beschreibung', @obj.description('de'))
  assert_equal('eine Beschreibung', @obj.description('fr'))
  assert_equal('eine Beschreibung', @obj.description)
  values = {
    'en' =>  'a description',
  }
  @obj.update_values(values)
  assert_equal('eine Beschreibung', @obj.description('de'))
  assert_equal('eine Beschreibung', @obj.description('fr'))
  assert_equal('a description', @obj.description('en'))
  values = {
    'de' =>  'eine andere Beschreibung',
  }
  @obj.update_values(values)
  assert_equal('eine andere Beschreibung', @obj.description('de'))
  assert_equal('eine andere Beschreibung', @obj.description('fr'))
  assert_equal('a description', @obj.description('en'))
  values = {
    'fr' =>  'une description',
  }
  @obj.update_values(values)
  assert_equal('eine andere Beschreibung', @obj.description('de'))
  assert_equal('une description', @obj.description('fr'))
  assert_equal('a description', @obj.description('en'))
end