summaryrefslogtreecommitdiff
path: root/spec/mspec/lib/mspec/matchers/have_private_method.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/mspec/lib/mspec/matchers/have_private_method.rb')
-rw-r--r--spec/mspec/lib/mspec/matchers/have_private_method.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/mspec/lib/mspec/matchers/have_private_method.rb b/spec/mspec/lib/mspec/matchers/have_private_method.rb
new file mode 100644
index 0000000000..d99d4ccb7f
--- /dev/null
+++ b/spec/mspec/lib/mspec/matchers/have_private_method.rb
@@ -0,0 +1,24 @@
+require 'mspec/matchers/method'
+
+class HavePrivateMethodMatcher < MethodMatcher
+ def matches?(mod)
+ @mod = mod
+ mod.private_methods(@include_super).include? @method
+ end
+
+ def failure_message
+ ["Expected #{@mod} to have private method '#{@method.to_s}'",
+ "but it does not"]
+ end
+
+ def negative_failure_message
+ ["Expected #{@mod} NOT to have private method '#{@method.to_s}'",
+ "but it does"]
+ end
+end
+
+class Object
+ def have_private_method(method, include_super=true)
+ HavePrivateMethodMatcher.new method, include_super
+ end
+end