Class: IVarsTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/fixture_background/ivars.rb

Instance Method Summary collapse

Instance Method Details

#test_raises_exception_if_some_var_does_not_respond_to_findObject



104
105
106
107
108
109
110
# File 'lib/fixture_background/ivars.rb', line 104

def test_raises_exception_if_some_var_does_not_respond_to_find
  data = [
    :some => 1
  ]
  
  assert_raises(ArgumentError) { IVars.serialize(data) }
end

#test_serialize_arraysObject



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/fixture_background/ivars.rb', line 80

def test_serialize_arrays
  data = {
    :hase => [Record.find(1), Record.find(2), [Record.find(3), Record.find(4)]] 
  }

  expected = {
    :hase => ['Record#1', 'Record#2', ['Record#3', 'Record#4']]
  }
  
  assert_serialize_deserialize expected, data
end

#test_serialize_hashObject



92
93
94
95
96
97
98
99
100
101
102
# File 'lib/fixture_background/ivars.rb', line 92

def test_serialize_hash
  data = {
    :hase => { 'thies' => [Record.find(1), Record.find(2)], :sebastian => [Record.find(3), Record.find(4)]}
  }

  expected = {
    :hase => {'thies' => ['Record#1', 'Record#2'], :sebastian => ['Record#3', 'Record#4']}
  }
  
  assert_serialize_deserialize expected, data
end

#test_serialize_simple_valuesObject



66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/fixture_background/ivars.rb', line 66

def test_serialize_simple_values
  data = {
    :hase => Record.find(1), 
    :igel => Record.find(2)
  }

  expected = {
    :hase => 'Record#1',
    :igel => 'Record#2'
  }
  
  assert_serialize_deserialize expected, data
end