blob: f86d4249b2b765dd2351362f99a14d0a0ccfda1b (
plain)
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
|
require File.expand_path('../helper', __FILE__)
require 'rake/private_reader'
class TestPrivateAttrs < Rake::TestCase
class Sample
include Rake::PrivateReader
private_reader :reader, :a
def initialize
@reader = :RVALUE
end
def get_reader
reader
end
end
def setup
super
@sample = Sample.new
end
def test_private_reader_is_private
assert_private do @sample.reader end
assert_private do @sample.a end
end
def test_private_reader_returns_data
assert_equal :RVALUE, @sample.get_reader
end
private
def assert_private
ex = assert_raises(NoMethodError) do yield end
assert_match(/private/, ex.message)
end
end
|