Skip to content

Instantly share code, notes, and snippets.

@kronos
Created March 31, 2010 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kronos/350826 to your computer and use it in GitHub Desktop.
Save kronos/350826 to your computer and use it in GitHub Desktop.
diff --git a/spec/ruby/language/defined_spec.rb b/spec/ruby/language/defined_spec.rb
index 516f86b..e665fa0 100644
--- a/spec/ruby/language/defined_spec.rb
+++ b/spec/ruby/language/defined_spec.rb
@@ -43,6 +43,10 @@ describe "The defined? keyword when called with a method name" do
defined?(Object.print).should be_nil
end
+ it "returns nil if the method is protected" do
+ defined?(DefinedSpecs::Basic.new.protected_method).should be_nil
+ end
+
it "returns nil if the method is not defined" do
defined?(Kernel.defined_specs_undefined_method).should be_nil
end
diff --git a/spec/ruby/language/fixtures/defined.rb b/spec/ruby/language/fixtures/defined.rb
index 2b9628c..7a7243a 100644
--- a/spec/ruby/language/fixtures/defined.rb
+++ b/spec/ruby/language/fixtures/defined.rb
@@ -29,6 +29,10 @@ module DefinedSpecs
def a_defined_method
end
+ def protected_method
+ end
+ protected :protected_method
+
def local_variable_defined
x = 2
defined? x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment