summaryrefslogtreecommitdiff
path: root/test/rake/test_private_reader.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-15 21:59:37 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-15 21:59:37 +0000
commit9c66bad9f3d522d50d4a45ef8a3a92abbf93229f (patch)
tree8fc1ae219e41bdd711442b1d35149da4f45dfa8a /test/rake/test_private_reader.rb
parentbfc95c6e1639edc909338ef4d20d990caf6f630e (diff)
* lib/rake*: Updated to rake 0.9.3
* test/rake*: ditto * bin/rake: ditto * NEWS: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rake/test_private_reader.rb')
-rw-r--r--test/rake/test_private_reader.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/rake/test_private_reader.rb b/test/rake/test_private_reader.rb
new file mode 100644
index 00000000000..f86d4249b2b
--- /dev/null
+++ b/test/rake/test_private_reader.rb
@@ -0,0 +1,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