Class: TestCssTemplate

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
test/test_util/csstemplate.rb

Constant Summary

TEST_CSS_DIRECTORY =
File.expand_path('../data/css/foo', File.dirname(__FILE__))

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



34
35
36
37
38
39
# File 'test/test_util/csstemplate.rb', line 34

def setup
  @foo  =  {
    :bar_bg          => 'black',
    :bar_txt_color =>  'white',
  }
end

- (Object) teardown



40
41
42
# File 'test/test_util/csstemplate.rb', line 40

def teardown
  File.delete(TEST_CSS_DIRECTORY + '/oddb.css') if File.exist?(TEST_CSS_DIRECTORY + '/oddb.css')
end

- (Object) test_output_path



43
44
45
46
47
# File 'test/test_util/csstemplate.rb', line 43

def test_output_path
  result = ODDB::CssTemplate.output_path(:foo)
  expected = File.expand_path('../data/css/foo/oddb.css', File.dirname(__FILE__))
  assert_equal(expected, result)
end

- (Object) test_resolve



48
49
50
51
52
53
# File 'test/test_util/csstemplate.rb', line 48

def test_resolve
  var = 'bar_bg'
  result = ODDB::CssTemplate.resolve(var, @foo)
  expected = 'black'
  assert_equal(expected, result)
end

- (Object) test_resolve_default



54
55
56
57
58
59
# File 'test/test_util/csstemplate.rb', line 54

def test_resolve_default
  var = 'bar_link_color'
  result = ODDB::CssTemplate.resolve(var, @foo)
  expected = 'gold'
  assert_equal(expected, result)
end

- (Object) test_substitute



60
61
62
63
64
65
# File 'test/test_util/csstemplate.rb', line 60

def test_substitute
  src = '$foobar' 
  assert_raises(RuntimeError){
    ODDB::CssTemplate.substitute(src, @foo)
  }
end

- (Object) test_substitute2



66
67
68
69
# File 'test/test_util/csstemplate.rb', line 66

def test_substitute2
  src = '$bar_bg' 
  assert_equal('black', ODDB::CssTemplate.substitute(src, @foo))
end

- (Object) test_substitute3



70
71
72
73
# File 'test/test_util/csstemplate.rb', line 70

def test_substitute3
  src = 'bar_bg'  
  assert_equal('bar_bg', ODDB::CssTemplate.substitute(src, @foo))
end

- (Object) test_substitute4



74
75
76
77
78
# File 'test/test_util/csstemplate.rb', line 74

def test_substitute4
  src = "background-color: $bar_bg;\nlink-color: $bar_link_color;\n" 
  expected = "background-color: black;\nlink-color: gold;\n" 
  assert_equal(expected, ODDB::CssTemplate.substitute(src, @foo))
end

- (Object) test_write_css



87
88
89
90
# File 'test/test_util/csstemplate.rb', line 87

def test_write_css
  ODDB::CssTemplate.write_css
  assert(File.exist?(TEST_CSS_DIRECTORY + '/oddb.css'))
end