operating_system_helper_test.rb
2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
require File.dirname(__FILE__) + '/../../../../test/test_helper'
OperatingSystemName.create(:name=>"Debina")
OperatingSystemName.create(:name=>"Fedora")
OperatingSystemName.create(:name=>"CentOS")
class OperatingSystemHelperTest < ActiveSupport::TestCase
def setup
@operating_system_objects = [
{:operating_system_name_id => "1" ,:version => "2.0"},
{:operating_system_name_id => "2" ,"version" => "2.1"},
{:operating_system_name_id => "3" ,"version" => "2.2"}
]
@operating_system_objects
end
def teardown
@operating_system_objects = nil
end
should "return an empty list" do
empty_list = []
assert_equal [],OperatingSystemHelper.list_operating_system(empty_list)
end
should "return a list with current OperatingSystems" do
list_compare = []
list_op = OperatingSystemHelper.list_operating_system(@operating_system_objects)
assert_equal list_compare.class, list_op.class
end
should "have same information from the list passed as parameter" do
list_compare = OperatingSystemHelper.list_operating_system(@operating_system_objects)
first_operating = @operating_system_objects.first[:operating_system_name_id]
assert_equal first_operating, list_compare.first.operating_system_name_id.to_s
end
should "return a list with the same size of the parameter" do
list_compare = OperatingSystemHelper.list_operating_system(@operating_system_objects)
assert_equal @operating_system_objects.count, list_compare.count
end
should "return false if list_operating_system are empty or null" do
list_compare = []
assert_equal false,OperatingSystemHelper.valid_list_operating_system?(list_compare)
end
should "return a html text with operating system" do
operating_systems = []
operating_system = OperatingSystemName.new
operating_system.name = "teste"
software_operating_system = OperatingSystem.new
software_operating_system.version = 2
software_operating_system.operating_system_name = operating_system
operating_systems << software_operating_system
op_table = OperatingSystemHelper.operating_system_as_tables(operating_systems)
assert_not_nil op_table.first.call.index(OperatingSystemName.first.name)
end
end