File: test-applier.rb

package info (click to toggle)
rabbit 3.0.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,220 kB
  • sloc: ruby: 29,637; lisp: 309; makefile: 43; sh: 7
file content (73 lines) | stat: -rw-r--r-- 2,248 bytes parent folder | download | duplicates (4)
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
65
66
67
68
69
70
71
72
73
# Copyright (C) 2012-2019  Kouhei Sutou <kou@cozmixng.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

require "rabbit/theme/applier"

class RabbitApplierTest < Test::Unit::TestCase
  def setup
    theme = Object.new
    def theme.slides
      Object.new
    end
    @applier = Rabbit::Theme::Applier.new(theme)
  end

  sub_test_case("#normalize_source") do
    def normalize_source(source)
      @applier.__send__(:normalize_source, source)
    end

    data("x large",
         ["x_large_font_size", "huge_font_size"],
         keep: true)
    data("xx large",
         ["xx_large_font_size", "very_huge_font_size"],
         keep: true)
    data("x large script",
         ["x_large_script_font_size", "huge_script_font_size"],
         keep: true)

    def test_reference
      after, before = data
      assert_equal("@#{after}",
                   normalize_source("@#{before}"))
    end

    def test_reference_in_parentheses
      after, before = data
      assert_equal("(@#{after})",
                   normalize_source("(@#{before})"))
    end

    def test_reference_with_arguments_in_parentheses
      after, before = data
      assert_equal("(xxx, @#{after}, xxx)",
                   normalize_source("(xxx, @#{before}, xxx)"))
    end

    def test_assign_without_space
      after, before = data
      assert_equal("@#{after}=111",
                   normalize_source("@#{before}=111"))
    end

    def test_assign_with_space
      after, before = data
      assert_equal("@#{after} = 111",
                   normalize_source("@#{before} = 111"))
    end
  end
end