summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyrylo Silin <kyrylosilin@gmail.com>2013-05-18 15:56:40 +0300
committerKyrylo Silin <kyrylosilin@gmail.com>2013-05-18 15:56:40 +0300
commita033bca33694899a2cf098ca54ddad38e87faac8 (patch)
tree8dd5285e6db19b1a6db20e1454926e45eb1c77a0
parentc95c25e4d8db2b757a43278cc85674a20b9644ec (diff)
downloadpry-wip.show-source-doc-super-kw-support.tar.gz
[TEMP] Write a bunch of failing testswip.show-source-doc-super-kw-support
-rw-r--r--spec/commands/show_doc_spec.rb58
-rw-r--r--spec/commands/show_source_spec.rb65
2 files changed, 121 insertions, 2 deletions
diff --git a/spec/commands/show_doc_spec.rb b/spec/commands/show_doc_spec.rb
index f69910e7..e2d3f49f 100644
--- a/spec/commands/show_doc_spec.rb
+++ b/spec/commands/show_doc_spec.rb
@@ -54,6 +54,9 @@ if !PryTestHelpers.mri18_and_no_real_source_location?
class Grungy < Classy
# grungy initialize??
def initialize(*args); end
+
+ # super grungy!
+ def super(*args); end
end
@o = Grungy.new
@@ -68,6 +71,59 @@ if !PryTestHelpers.mri18_and_no_real_source_location?
Object.remove_const(:Daddy)
end
+ describe "without the switch but with the super keyword" do
+ it "finds super methods docs without with the super keyword" do
+ fatty = Grungy.new
+
+ # fatty initialize!
+ def fatty.initialize
+ pry_eval(binding, 'show-doc super')
+ end
+
+ fatty.initialize.should =~ /grungy initialize/
+ end
+
+ it "allows getting method docs for a method called `super`" do
+ fatty = Grungy.new
+
+ # supa fatty
+ def fatty.super(*bars); end
+
+ # fatty initialize!
+ def fatty.initialize
+ pry_eval(binding, 'show-doc super')
+ end
+
+ fatty.initialize.should =~ /supa fatty/
+ end
+ end
+
+ describe "the switch plus the keyword" do
+ it "allows getting a super method docs of a method called `super`" do
+ fatty = Grungy.new
+
+ # super initialize!
+ def fatty.super(*bars); end
+
+ def fatty.initialize
+ pry_eval(binding, 'show-doc super --super')
+ end
+
+ fatty.initialize.should =~ /super grungy/
+ end
+
+ it "allows getting a second super method docs of a method with any name" do
+ fatty = Grungy.new
+
+ # fatty initialize!
+ def fatty.initialize
+ pry_eval(binding, 'show-doc super --super')
+ end
+
+ fatty.initialize.should =~ /classy initialize/
+ end
+ end
+
it "finds super method docs" do
output = pry_eval(binding, 'show-doc --super @o.initialize')
output.should =~ /grungy initialize/
@@ -95,7 +151,7 @@ if !PryTestHelpers.mri18_and_no_real_source_location?
output.should =~ /grungy initialize/
end
- it "finds super method docs without `--super` but with the `super` keyword" do
+ it "finds super methods docs with multiple --super" do
fatty = Grungy.new
fatty.extend Module.new {
diff --git a/spec/commands/show_source_spec.rb b/spec/commands/show_source_spec.rb
index d98f604c..bf3f99a0 100644
--- a/spec/commands/show_source_spec.rb
+++ b/spec/commands/show_source_spec.rb
@@ -172,6 +172,10 @@ if !PryTestHelpers.mri18_and_no_real_source_location?
def foo(*bars)
:super_wibble
end
+
+ def super(*bars)
+ :super_super
+ end
end
end
@@ -179,8 +183,67 @@ if !PryTestHelpers.mri18_and_no_real_source_location?
Object.remove_const(:Foo)
end
- it "finds super methods with explicit method argument" do
+ describe "without the switch but with the super keyword" do
+ it "finds super method" do
+ o = Foo.new
+
+ def o.foo(*bars)
+ :wibble
+ pry_eval(binding, 'show-source super')
+ end
+
+ o.foo.should =~ /:super_wibble/
+ end
+
+ it "allows getting a regular method called `super`" do
+ o = Foo.new
+
+ def o.super(*bars)
+ :nibble
+ end
+
+ def o.foo(*bars)
+ :wibble
+ pry_eval(binding, 'show-source super')
+ end
+
+ o.foo.should =~ /:nibble/
+ end
+ end
+ describe "the switch plus the keyword" do
+ it "allows getting a super method of a regular method called `super`" do
+ o = Foo.new
+
+ def o.super(*bars)
+ :nibble
+ end
+
+ def o.foo(*bars)
+ :wibble
+ pry_eval(binding, 'show-source super --super')
+ end
+
+ o.foo.should =~ /:super_super/
+ end
+
+ it "allows getting a second super method of a method with any name" do
+ klass = Class.new(Foo) {
+ def foo(*bars)
+ :middle_super_wibble
+ end
+ }
+ o = klass.new
+ def o.foo(*bars)
+ :wibble
+ pry_eval(binding, 'show-source super --super')
+ end
+
+ o.foo.should =~ /:super_wibble/
+ end
+ end
+
+ it "finds super methods with explicit method argument" do
o = Foo.new
def o.foo(*bars)
:wibble