Skip to content

Commit db1e226

Browse files
author
Michael Bulat
committed
adding non plural and test for singular to plural array storage
1 parent c3126b5 commit db1e226

File tree

4 files changed

+33
-7
lines changed

4 files changed

+33
-7
lines changed

test/serializer_test.rb

+25-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ class SerializerTest < Test::Unit::TestCase
44
context "Rubyprot serializer" do
55
setup do
66
@test_file_path = "test/test_files/dump"
7-
@object_name = "TestClass"
7+
@object_name = "Person"
8+
@object_name_ends_in_s = "TestClass"
89
end
910

1011
teardown do
@@ -16,7 +17,7 @@ class SerializerTest < Test::Unit::TestCase
1617

1718
should "raise error if dump path not set" do
1819
assert_raise RuntimeError do
19-
object = TestClass.new
20+
object = Person.new
2021
Rubyprot.serialize(object)
2122
end
2223
end
@@ -26,7 +27,7 @@ class SerializerTest < Test::Unit::TestCase
2627
Rubyprot.dump_path = @test_file_path
2728
end
2829

29-
object = TestClass.new
30+
object = Person.new
3031
Rubyprot.serialize(object)
3132

3233
assert_nothing_raised do
@@ -41,7 +42,7 @@ class SerializerTest < Test::Unit::TestCase
4142
Rubyprot.dump_path = @test_file_path
4243
end
4344

44-
object = TestClass.new
45+
object = Person.new
4546
Rubyprot.serialize(object)
4647

4748
assert_nothing_raised do
@@ -62,26 +63,43 @@ class SerializerTest < Test::Unit::TestCase
6263
Rubyprot.dump_path = @test_file_path
6364
end
6465

65-
object = TestClass.new
66+
object = Person.new
6667
name = Rubyprot.serialize(object)
6768

6869
assert_kind_of String, name
6970
end
7071

71-
should "return array string name for array" do
72+
should "return string plural name for array" do
7273
Rubyprot.configure do |config|
7374
Rubyprot.dump_path = @test_file_path
7475
end
7576

7677
array = Array.new
77-
object = TestClass.new
78+
object = Person.new
7879
array[0] = object
7980
array[1] = object
8081

8182
name = Rubyprot.serialize(array)
8283

8384
assert_kind_of String, name
85+
assert name == "Persons"
8486
end
87+
88+
should "return string plural name for array from object ending in s" do
89+
Rubyprot.configure do |config|
90+
Rubyprot.dump_path = @test_file_path
91+
end
92+
93+
array = Array.new
94+
object = TestClass.new
95+
array[0] = object
96+
array[1] = object
97+
98+
name = Rubyprot.serialize(array)
99+
100+
assert_kind_of String, name
101+
assert name == "TestClasses"
102+
end
85103
end
86104

87105

test/test_files/models/person.rb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Person
2+
attr_accessor :test_attr
3+
4+
def test_method
5+
return 'this method returned'
6+
end
7+
end

test/test_files/test_data/Person

12 Bytes
Binary file not shown.

test/test_helper.rb

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
require 'test_files/models/test_class'
99
require 'test_files/models/test_class_two'
1010
require 'test_files/models/test_module'
11+
require 'test_files/models/person'
1112

1213
class Test::Unit::TestCase
1314
end

0 commit comments

Comments
 (0)