mirror of
https://github.com/awesome-print/awesome_print
synced 2023-03-27 23:22:34 -04:00
All specs pass with Ruby 1.8.7/RSpec 1.3 and Ruby 1.9.2/RSpec 2.0
This commit is contained in:
parent
3ab0cbabc1
commit
a0dab8cd57
3 changed files with 25 additions and 28 deletions
|
@ -252,7 +252,7 @@ class AwesomePrint
|
||||||
owner = "#{$2}#{$1 ? '(unbound)' : ''}".gsub('(', ' (')
|
owner = "#{$2}#{$1 ? '(unbound)' : ''}".gsub('(', ' (')
|
||||||
end
|
end
|
||||||
|
|
||||||
[ method.name, "(#{args})", owner.to_s ]
|
[ method.name.to_s, "(#{args})", owner.to_s ]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Format hash keys as plain string regardless of underlying data type.
|
# Format hash keys as plain string regardless of underlying data type.
|
||||||
|
|
|
@ -12,13 +12,13 @@ describe "Single method" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain: should handle a method with one argument" do
|
it "plain: should handle a method with one argument" do
|
||||||
method = ''.method(:match)
|
method = ''.method(:include?)
|
||||||
method.ai(:plain => true).should == 'String#match(arg1)'
|
method.ai(:plain => true).should == 'String#include?(arg1)'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "color: should handle a method with one argument" do
|
it "color: should handle a method with one argument" do
|
||||||
method = ''.method(:match)
|
method = ''.method(:include?)
|
||||||
method.ai.should == "\e[1;33mString\e[0m#\e[1;35mmatch\e[0m\e[0;37m(arg1)\e[0m"
|
method.ai.should == "\e[1;33mString\e[0m#\e[1;35minclude?\e[0m\e[0;37m(arg1)\e[0m"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain: should handle a method with two arguments" do
|
it "plain: should handle a method with two arguments" do
|
||||||
|
@ -42,13 +42,13 @@ describe "Single method" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain: should handle a method defined in mixin" do
|
it "plain: should handle a method defined in mixin" do
|
||||||
method = ''.method(:grep)
|
method = ''.method(:is_a?)
|
||||||
method.ai(:plain => true).should == 'String (Enumerable)#grep(arg1)'
|
method.ai(:plain => true).should == 'String (Kernel)#is_a?(arg1)'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "color: should handle a method defined in mixin" do
|
it "color: should handle a method defined in mixin" do
|
||||||
method = ''.method(:grep)
|
method = ''.method(:is_a?)
|
||||||
method.ai.should == "\e[1;33mString (Enumerable)\e[0m#\e[1;35mgrep\e[0m\e[0;37m(arg1)\e[0m"
|
method.ai.should == "\e[1;33mString (Kernel)\e[0m#\e[1;35mis_a?\e[0m\e[0;37m(arg1)\e[0m"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain: should handle an unbound method" do
|
it "plain: should handle an unbound method" do
|
||||||
|
@ -71,37 +71,37 @@ end
|
||||||
|
|
||||||
describe "object.methods" do
|
describe "object.methods" do
|
||||||
it "index: should handle object.methods" do
|
it "index: should handle object.methods" do
|
||||||
out = nil.methods.ai(:plain => true).grep(/is_a\?/).first
|
out = nil.methods.ai(:plain => true).split("\n").grep(/is_a\?/).first
|
||||||
out.should =~ /^\s+\[\s*\d+\]\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)\n$/
|
out.should =~ /^\s+\[\s*\d+\]\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)$/
|
||||||
end
|
end
|
||||||
|
|
||||||
it "no index: should handle object.methods" do
|
it "no index: should handle object.methods" do
|
||||||
out = nil.methods.ai(:plain => true, :index => false).grep(/is_a\?/).first
|
out = nil.methods.ai(:plain => true, :index => false).split("\n").grep(/is_a\?/).first
|
||||||
out.should =~ /^\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)\n$/
|
out.should =~ /^\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)$/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "object.public_methods" do
|
describe "object.public_methods" do
|
||||||
it "index: should handle object.public_methods" do
|
it "index: should handle object.public_methods" do
|
||||||
out = nil.public_methods.ai(:plain => true).grep(/is_a\?/).first
|
out = nil.public_methods.ai(:plain => true).split("\n").grep(/is_a\?/).first
|
||||||
out.should =~ /^\s+\[\s*\d+\]\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)\n$/
|
out.should =~ /^\s+\[\s*\d+\]\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)$/
|
||||||
end
|
end
|
||||||
|
|
||||||
it "no index: should handle object.public_methods" do
|
it "no index: should handle object.public_methods" do
|
||||||
out = nil.public_methods.ai(:plain => true, :index => false).grep(/is_a\?/).first
|
out = nil.public_methods.ai(:plain => true, :index => false).split("\n").grep(/is_a\?/).first
|
||||||
out.should =~ /^\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)\n$/
|
out.should =~ /^\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)$/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "object.private_methods" do
|
describe "object.private_methods" do
|
||||||
it "index: should handle object.private_methods" do
|
it "index: should handle object.private_methods" do
|
||||||
out = nil.private_methods.ai(:plain => true).grep(/sleep/).first
|
out = nil.private_methods.ai(:plain => true).split("\n").grep(/sleep/).first
|
||||||
out.should =~ /^\s+\[\s*\d+\]\s+sleep\(arg1,\s\.{3}\)\s+NilClass \(Kernel\)\n$/
|
out.should =~ /^\s+\[\s*\d+\]\s+sleep\(arg1,\s\.{3}\)\s+NilClass \(Kernel\)$/
|
||||||
end
|
end
|
||||||
|
|
||||||
it "no index: should handle object.private_methods" do
|
it "no index: should handle object.private_methods" do
|
||||||
out = nil.private_methods.ai(:plain => true, :index => false).grep(/sleep/).first
|
out = nil.private_methods.ai(:plain => true, :index => false).split("\n").grep(/sleep/).first
|
||||||
out.should =~ /^\s+sleep\(arg1,\s\.{3}\)\s+NilClass \(Kernel\)\n$/
|
out.should =~ /^\s+sleep\(arg1,\s\.{3}\)\s+NilClass \(Kernel\)$/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,12 @@
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Running specs with Ruby 1.8.7 and RSpec 1.3+:
|
# Running specs with Ruby 1.8.7 and RSpec 1.3+:
|
||||||
# $ rake spec # Entire spec suite.
|
# $ rake spec # Entire spec suite.
|
||||||
# $ ruby --color -rubygems spec/logger_spec.rb # Individual spec file.
|
# $ ruby -rubygems spec/logger_spec.rb # Individual spec file.
|
||||||
#
|
#
|
||||||
# Running specs with Ruby 1.9.2 and RSpec 2.0+:
|
# Running specs with Ruby 1.9.2 and RSpec 2.0+:
|
||||||
# $ rake spec # Entire spec suite.
|
# $ rake spec # Entire spec suite.
|
||||||
# $ rspec --color spec/logger_spec.rb # Individual spec file.
|
# $ rspec spec/logger_spec.rb # Individual spec file.
|
||||||
#
|
#
|
||||||
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
||||||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
||||||
|
@ -20,9 +20,6 @@ if RUBY_VERSION.to_f < 1.9
|
||||||
require 'spec'
|
require 'spec'
|
||||||
require 'spec/autorun'
|
require 'spec/autorun'
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
|
|
||||||
Spec::Runner.configure do |config|
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def stub_dotfile!
|
def stub_dotfile!
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue