File: test_comments.rb

package info (click to toggle)
ruby-roo 3.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 8,216 kB
  • sloc: ruby: 6,529; xml: 88; makefile: 6
file content (54 lines) | stat: -rw-r--r-- 1,838 bytes parent folder | download
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
module TestComments
  def test_comment
    options = { name: "comments", format: [:openoffice, :libreoffice, :excelx] }
    with_each_spreadsheet(options) do |oo|
      assert_equal "Kommentar fuer B4", oo.comment("b", 4)
      assert_equal "Kommentar fuer B5", oo.comment("b", 5)
    end
  end

  def test_no_comment
    options = { name: "comments", format: [:openoffice, :excelx] }
    with_each_spreadsheet(options) do |oo|
      # There are no comments at the second sheet.
      assert_nil oo.comment("b", 4, oo.sheets[1])
    end
  end

  def test_comments
    options = { name: "comments", format: [:openoffice, :libreoffice, :excelx] }
    expexted_comments = [
      [4, 2, "Kommentar fuer B4"],
      [5, 2, "Kommentar fuer B5"],
    ]

    with_each_spreadsheet(options) do |oo|
      assert_equal expexted_comments, oo.comments(oo.sheets.first), "comments error in class #{oo.class}"
    end
  end

  def test_empty_sheet_comments
    options = { name: "emptysheets", format: [:openoffice, :excelx] }
    with_each_spreadsheet(options) do |oo|
      assert_equal [], oo.comments, "An empty sheet's formulas should be an empty array"
    end
  end

  def test_comments_from_google_sheet_exported_as_xlsx
    expected_comments = [[1, 1, "this is a comment\n\t-Steven Daniels"]]
    with_each_spreadsheet(name: "comments-google", format: [:excelx]) do |oo|
      assert_equal expected_comments, oo.comments(oo.sheets.first), "comments error in class #{oo.class}"
    end
  end

  def test_excel_comment_with_author
    options = { name: "comments-with-author", format: [:excelx] }
    expexted_comments = [
      [6, 2, "Eli Wang:\ncomment with author"]
    ]

    with_each_spreadsheet(options) do |oo|
      assert_equal expexted_comments, oo.comments(oo.sheets.first), "comments error in class #{oo.class}"
    end
  end
end