PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 8ms RepoModel.GetById 33ms app.codeStats 0ms

/vendor/gems/facets-2.4.5/test/core/class/test_cattr.rb

https://bitbucket.org/mediashelf/fedora-migrator
Ruby | 47 lines | 40 code | 7 blank | 0 comment | 0 complexity | f4d0ced15650e26b4ef046b32e7e435b MD5 | raw file
 1require 'facets/class/cattr.rb'
 2require 'test/unit'
 3
 4class TCModule < Test::Unit::TestCase
 5
 6  class MockObject
 7    def initialize
 8      @@a = 10
 9    end
10    def b ; @@b ; end
11  end
12
13  def test_cattr
14    assert_nothing_raised {
15      MockObject.class_eval { cattr :a }
16    }
17    t = MockObject.new
18    assert_equal( 10, t.a )
19  end
20
21  def test_cattr_reader
22    assert_nothing_raised {
23      MockObject.class_eval { cattr_reader :a }
24    }
25    t = MockObject.new
26    assert_equal( 10, t.a )
27  end
28
29  def test_cattr_writer
30    assert_nothing_raised {
31      MockObject.class_eval { cattr_writer :b }
32    }
33    t = MockObject.new
34    t.b = 5
35    assert_equal( 5, t.b )
36  end
37
38  def test_cattr_accessor
39    assert_nothing_raised {
40      MockObject.class_eval { cattr_accessor :c }
41    }
42    t = MockObject.new
43    t.c = 50
44    assert_equal( 50, t.c )
45  end
46
47end