library_helper_test.rb
1.65 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
require File.dirname(__FILE__) + '/../../../../test/test_helper'
class LibraryHelperTest < ActiveSupport::TestCase
  include LibraryHelper
  def setup
    @license_objects = [{"name" => "license1" ,"version" => "2.0", "license" => "debian", "software_id" => "1"},
      {"name" => "license2" ,"version" => "2.1", "license" => "debian", "software_id" => "1"},
      {"name" => "license3" ,"version" => "2.2", "license" => "debian", "software_id" => "1"}]
  end
  def teardown
    @license_objects = nil
  end
  should "return an empty list" do
    empty_list = []
    assert_equal  [],LibraryHelper.list_libraries(empty_list)
  end
  should "return a list with current library objects" do
    list_compare = []
    assert_equal  list_compare.class, LibraryHelper.list_libraries(@license_objects).class
  end
  should "have same information from the list passed as parameter" do
    list_compare = LibraryHelper.list_libraries(@license_objects)
    assert_equal @license_objects.first[:name], list_compare.first.name
  end
  should "return a list with the same size of the parameter" do
    list_compare = LibraryHelper.list_libraries(@license_objects)
    assert_equal @license_objects.count, list_compare.count
  end
  should "return false if list_database are empty or null" do
    list_compare = []
    assert_equal true, LibraryHelper.valid_list_libraries?(list_compare)
  end
  should "return a html text with license name equals to linux" do
    libraries = []
    library_description = Library.new
    library_description.name = "Lib"
    libraries << library_description
    assert_not_nil LibraryHelper.library_as_tables(libraries).first.call.index("lib")
  end
end