From a0dab8cd57c4afb5e7ce2a942996fa235387d425 Mon Sep 17 00:00:00 2001 From: Mike Dvorkin Date: Sun, 31 Oct 2010 22:34:50 -0700 Subject: [PATCH] All specs pass with Ruby 1.8.7/RSpec 1.3 and Ruby 1.9.2/RSpec 2.0 --- lib/ap/awesome_print.rb | 2 +- spec/methods_spec.rb | 40 ++++++++++++++++++++-------------------- spec/spec_helper.rb | 11 ++++------- 3 files changed, 25 insertions(+), 28 deletions(-) diff --git a/lib/ap/awesome_print.rb b/lib/ap/awesome_print.rb index 833b716..fc0b147 100755 --- a/lib/ap/awesome_print.rb +++ b/lib/ap/awesome_print.rb @@ -252,7 +252,7 @@ class AwesomePrint owner = "#{$2}#{$1 ? '(unbound)' : ''}".gsub('(', ' (') end - [ method.name, "(#{args})", owner.to_s ] + [ method.name.to_s, "(#{args})", owner.to_s ] end # Format hash keys as plain string regardless of underlying data type. diff --git a/spec/methods_spec.rb b/spec/methods_spec.rb index d6eb891..6a7b526 100644 --- a/spec/methods_spec.rb +++ b/spec/methods_spec.rb @@ -12,13 +12,13 @@ describe "Single method" do end it "plain: should handle a method with one argument" do - method = ''.method(:match) - method.ai(:plain => true).should == 'String#match(arg1)' + method = ''.method(:include?) + method.ai(:plain => true).should == 'String#include?(arg1)' end it "color: should handle a method with one argument" do - method = ''.method(:match) - method.ai.should == "\e[1;33mString\e[0m#\e[1;35mmatch\e[0m\e[0;37m(arg1)\e[0m" + method = ''.method(:include?) + method.ai.should == "\e[1;33mString\e[0m#\e[1;35minclude?\e[0m\e[0;37m(arg1)\e[0m" end it "plain: should handle a method with two arguments" do @@ -42,13 +42,13 @@ describe "Single method" do end it "plain: should handle a method defined in mixin" do - method = ''.method(:grep) - method.ai(:plain => true).should == 'String (Enumerable)#grep(arg1)' + method = ''.method(:is_a?) + method.ai(:plain => true).should == 'String (Kernel)#is_a?(arg1)' end it "color: should handle a method defined in mixin" do - method = ''.method(:grep) - method.ai.should == "\e[1;33mString (Enumerable)\e[0m#\e[1;35mgrep\e[0m\e[0;37m(arg1)\e[0m" + method = ''.method(:is_a?) + method.ai.should == "\e[1;33mString (Kernel)\e[0m#\e[1;35mis_a?\e[0m\e[0;37m(arg1)\e[0m" end it "plain: should handle an unbound method" do @@ -71,37 +71,37 @@ end describe "object.methods" do it "index: should handle object.methods" do - out = nil.methods.ai(:plain => true).grep(/is_a\?/).first - out.should =~ /^\s+\[\s*\d+\]\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)\n$/ + out = nil.methods.ai(:plain => true).split("\n").grep(/is_a\?/).first + out.should =~ /^\s+\[\s*\d+\]\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)$/ end it "no index: should handle object.methods" do - out = nil.methods.ai(:plain => true, :index => false).grep(/is_a\?/).first - out.should =~ /^\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)\n$/ + out = nil.methods.ai(:plain => true, :index => false).split("\n").grep(/is_a\?/).first + out.should =~ /^\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)$/ end end describe "object.public_methods" do it "index: should handle object.public_methods" do - out = nil.public_methods.ai(:plain => true).grep(/is_a\?/).first - out.should =~ /^\s+\[\s*\d+\]\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)\n$/ + 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\)$/ end it "no index: should handle object.public_methods" do - out = nil.public_methods.ai(:plain => true, :index => false).grep(/is_a\?/).first - out.should =~ /^\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)\n$/ + out = nil.public_methods.ai(:plain => true, :index => false).split("\n").grep(/is_a\?/).first + out.should =~ /^\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)$/ end end describe "object.private_methods" do it "index: should handle object.private_methods" do - out = nil.private_methods.ai(:plain => true).grep(/sleep/).first - out.should =~ /^\s+\[\s*\d+\]\s+sleep\(arg1,\s\.{3}\)\s+NilClass \(Kernel\)\n$/ + 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\)$/ end it "no index: should handle object.private_methods" do - out = nil.private_methods.ai(:plain => true, :index => false).grep(/sleep/).first - out.should =~ /^\s+sleep\(arg1,\s\.{3}\)\s+NilClass \(Kernel\)\n$/ + out = nil.private_methods.ai(:plain => true, :index => false).split("\n").grep(/sleep/).first + out.should =~ /^\s+sleep\(arg1,\s\.{3}\)\s+NilClass \(Kernel\)$/ end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f3076dc..002a9bf 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -5,12 +5,12 @@ #------------------------------------------------------------------------------ # # Running specs with Ruby 1.8.7 and RSpec 1.3+: -# $ rake spec # Entire spec suite. -# $ ruby --color -rubygems spec/logger_spec.rb # Individual spec file. +# $ rake spec # Entire spec suite. +# $ ruby -rubygems spec/logger_spec.rb # Individual spec file. # # Running specs with Ruby 1.9.2 and RSpec 2.0+: -# $ rake spec # Entire spec suite. -# $ rspec --color spec/logger_spec.rb # Individual spec file. +# $ rake spec # Entire spec suite. +# $ rspec spec/logger_spec.rb # Individual spec file. # $LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) @@ -20,9 +20,6 @@ if RUBY_VERSION.to_f < 1.9 require 'spec' require 'spec/autorun' require 'rubygems' - - Spec::Runner.configure do |config| - end end def stub_dotfile!