mirror of
https://github.com/awesome-print/awesome_print
synced 2023-03-27 23:22:34 -04:00
update rspec syntax from should to expect via transpec
This commit is contained in:
parent
0bd3425caf
commit
2bc678bba5
15 changed files with 222 additions and 222 deletions
|
@ -30,14 +30,14 @@ describe "AwesomePrint" do
|
||||||
|
|
||||||
it "colorizes tty processes by default" do
|
it "colorizes tty processes by default" do
|
||||||
stub_tty!
|
stub_tty!
|
||||||
@arr.ai(:multiline => false).should == COLORIZED
|
expect(@arr.ai(:multiline => false)).to eq(COLORIZED)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "colorizes processes with ENV['ANSICON'] by default" do
|
it "colorizes processes with ENV['ANSICON'] by default" do
|
||||||
begin
|
begin
|
||||||
stub_tty!
|
stub_tty!
|
||||||
term, ENV['ANSICON'] = ENV['ANSICON'], "1"
|
term, ENV['ANSICON'] = ENV['ANSICON'], "1"
|
||||||
@arr.ai(:multiline => false).should == COLORIZED
|
expect(@arr.ai(:multiline => false)).to eq(COLORIZED)
|
||||||
ensure
|
ensure
|
||||||
ENV['ANSICON'] = term
|
ENV['ANSICON'] = term
|
||||||
end
|
end
|
||||||
|
@ -47,7 +47,7 @@ describe "AwesomePrint" do
|
||||||
begin
|
begin
|
||||||
stub_tty!
|
stub_tty!
|
||||||
term, ENV['TERM'] = ENV['TERM'], "dumb"
|
term, ENV['TERM'] = ENV['TERM'], "dumb"
|
||||||
@arr.ai(:multiline => false).should == PLAIN
|
expect(@arr.ai(:multiline => false)).to eq(PLAIN)
|
||||||
ensure
|
ensure
|
||||||
ENV['TERM'] = term
|
ENV['TERM'] = term
|
||||||
end
|
end
|
||||||
|
@ -56,7 +56,7 @@ describe "AwesomePrint" do
|
||||||
it "does not colorize subprocesses by default" do
|
it "does not colorize subprocesses by default" do
|
||||||
begin
|
begin
|
||||||
stub_tty! false
|
stub_tty! false
|
||||||
@arr.ai(:multiline => false).should == PLAIN
|
expect(@arr.ai(:multiline => false)).to eq(PLAIN)
|
||||||
ensure
|
ensure
|
||||||
stub_tty!
|
stub_tty!
|
||||||
end
|
end
|
||||||
|
@ -70,14 +70,14 @@ describe "AwesomePrint" do
|
||||||
|
|
||||||
it "still colorizes tty processes" do
|
it "still colorizes tty processes" do
|
||||||
stub_tty!
|
stub_tty!
|
||||||
@arr.ai(:multiline => false).should == COLORIZED
|
expect(@arr.ai(:multiline => false)).to eq(COLORIZED)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "colorizes processes with ENV['ANSICON'] set to 0" do
|
it "colorizes processes with ENV['ANSICON'] set to 0" do
|
||||||
begin
|
begin
|
||||||
stub_tty!
|
stub_tty!
|
||||||
term, ENV['ANSICON'] = ENV['ANSICON'], "1"
|
term, ENV['ANSICON'] = ENV['ANSICON'], "1"
|
||||||
@arr.ai(:multiline => false).should == COLORIZED
|
expect(@arr.ai(:multiline => false)).to eq(COLORIZED)
|
||||||
ensure
|
ensure
|
||||||
ENV['ANSICON'] = term
|
ENV['ANSICON'] = term
|
||||||
end
|
end
|
||||||
|
@ -87,7 +87,7 @@ describe "AwesomePrint" do
|
||||||
begin
|
begin
|
||||||
stub_tty!
|
stub_tty!
|
||||||
term, ENV['TERM'] = ENV['TERM'], "dumb"
|
term, ENV['TERM'] = ENV['TERM'], "dumb"
|
||||||
@arr.ai(:multiline => false).should == COLORIZED
|
expect(@arr.ai(:multiline => false)).to eq(COLORIZED)
|
||||||
ensure
|
ensure
|
||||||
ENV['TERM'] = term
|
ENV['TERM'] = term
|
||||||
end
|
end
|
||||||
|
@ -96,7 +96,7 @@ describe "AwesomePrint" do
|
||||||
it "colorizes subprocess" do
|
it "colorizes subprocess" do
|
||||||
begin
|
begin
|
||||||
stub_tty! false
|
stub_tty! false
|
||||||
@arr.ai(:multiline => false).should == COLORIZED
|
expect(@arr.ai(:multiline => false)).to eq(COLORIZED)
|
||||||
ensure
|
ensure
|
||||||
stub_tty!
|
stub_tty!
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,8 +11,8 @@ describe "AwesomePrint logging extensions" do
|
||||||
|
|
||||||
describe "ap method" do
|
describe "ap method" do
|
||||||
it "should awesome_inspect the given object" do
|
it "should awesome_inspect the given object" do
|
||||||
object = mock
|
object = double
|
||||||
object.should_receive(:ai)
|
expect(object).to receive(:ai)
|
||||||
@logger.ap object
|
@logger.ap object
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,18 +22,18 @@ describe "AwesomePrint logging extensions" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should fallback to the default :debug log level" do
|
it "should fallback to the default :debug log level" do
|
||||||
@logger.should_receive(:debug)
|
expect(@logger).to receive(:debug)
|
||||||
@logger.ap(nil)
|
@logger.ap(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should use the global user default if no level passed" do
|
it "should use the global user default if no level passed" do
|
||||||
AwesomePrint.defaults = { :log_level => :info }
|
AwesomePrint.defaults = { :log_level => :info }
|
||||||
@logger.should_receive(:info)
|
expect(@logger).to receive(:info)
|
||||||
@logger.ap(nil)
|
@logger.ap(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should use the passed in level" do
|
it "should use the passed in level" do
|
||||||
@logger.should_receive(:warn)
|
expect(@logger).to receive(:warn)
|
||||||
@logger.ap(nil, :warn)
|
@logger.ap(nil, :warn)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,18 +3,18 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
||||||
describe "String extensions" do
|
describe "String extensions" do
|
||||||
[ :gray, :red, :green, :yellow, :blue, :purple, :cyan, :white ].each_with_index do |color, i|
|
[ :gray, :red, :green, :yellow, :blue, :purple, :cyan, :white ].each_with_index do |color, i|
|
||||||
it "should have #{color} color" do
|
it "should have #{color} color" do
|
||||||
color.to_s.send(color).should == "\e[1;#{30+i}m#{color}\e[0m"
|
expect(color.to_s.send(color)).to eq("\e[1;#{30+i}m#{color}\e[0m")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should have #{color}ish color" do
|
it "should have #{color}ish color" do
|
||||||
color.to_s.send(:"#{color}ish").should == "\e[0;#{30+i}m#{color}\e[0m"
|
expect(color.to_s.send(:"#{color}ish")).to eq("\e[0;#{30+i}m#{color}\e[0m")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should have black and pale colors" do
|
it "should have black and pale colors" do
|
||||||
"black".send(:black).should == "black".send(:grayish)
|
expect("black".send(:black)).to eq("black".send(:grayish))
|
||||||
"pale".send(:pale).should == "pale".send(:whiteish)
|
expect("pale".send(:pale)).to eq("pale".send(:whiteish))
|
||||||
"pale".send(:pale).should == "\e[0;37mpale\e[0m"
|
expect("pale".send(:pale)).to eq("\e[0;37mpale\e[0m")
|
||||||
"whiteish".send(:whiteish).should == "\e[0;37mwhiteish\e[0m"
|
expect("whiteish".send(:whiteish)).to eq("\e[0;37mwhiteish\e[0m")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,12 +11,12 @@ begin
|
||||||
|
|
||||||
it "uses HTML and adds 'debug_dump' class to plain <pre> tag" do
|
it "uses HTML and adds 'debug_dump' class to plain <pre> tag" do
|
||||||
markup = rand
|
markup = rand
|
||||||
@view.ap(markup, :plain => true).should == %Q|<pre class="debug_dump">#{markup}</pre>|
|
expect(@view.ap(markup, :plain => true)).to eq(%Q|<pre class="debug_dump">#{markup}</pre>|)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "uses HTML and adds 'debug_dump' class to colorized <pre> tag" do
|
it "uses HTML and adds 'debug_dump' class to colorized <pre> tag" do
|
||||||
markup = ' &<hello>'
|
markup = ' &<hello>'
|
||||||
@view.ap(markup).should == '<pre class="debug_dump"><kbd style="color:brown">" &<hello>"</kbd></pre>'
|
expect(@view.ap(markup)).to eq('<pre class="debug_dump"><kbd style="color:brown">" &<hello>"</kbd></pre>')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ EOS
|
||||||
else
|
else
|
||||||
str.sub!('?', '1992-10-10 12:30:00 UTC')
|
str.sub!('?', '1992-10-10 12:30:00 UTC')
|
||||||
end
|
end
|
||||||
out.gsub(/0x([a-f\d]+)/, "0x01234567").should == str
|
expect(out.gsub(/0x([a-f\d]+)/, "0x01234567")).to eq(str)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "display multiple records" do
|
it "display multiple records" do
|
||||||
|
@ -109,7 +109,7 @@ EOS
|
||||||
str.sub!('??', '1992-10-10 12:30:00 UTC')
|
str.sub!('??', '1992-10-10 12:30:00 UTC')
|
||||||
str.sub!('?!', '2003-05-26 14:15:00 UTC')
|
str.sub!('?!', '2003-05-26 14:15:00 UTC')
|
||||||
end
|
end
|
||||||
out.gsub(/0x([a-f\d]+)/, "0x01234567").should == str
|
expect(out.gsub(/0x([a-f\d]+)/, "0x01234567")).to eq(str)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ EOS
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
str.sub!('?', '1992-10-10 12:30:00')
|
str.sub!('?', '1992-10-10 12:30:00')
|
||||||
out.gsub(/0x([a-f\d]+)/, "0x01234567").should == str
|
expect(out.gsub(/0x([a-f\d]+)/, "0x01234567")).to eq(str)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "display multiple records" do
|
it "display multiple records" do
|
||||||
|
@ -355,7 +355,7 @@ EOS
|
||||||
end
|
end
|
||||||
str.sub!('?', '1992-10-10 12:30:00')
|
str.sub!('?', '1992-10-10 12:30:00')
|
||||||
str.sub!('?', '2003-05-26 14:15:00')
|
str.sub!('?', '2003-05-26 14:15:00')
|
||||||
out.gsub(/0x([a-f\d]+)/, "0x01234567").should == str
|
expect(out.gsub(/0x([a-f\d]+)/, "0x01234567")).to eq(str)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -366,7 +366,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should print the class" do
|
it "should print the class" do
|
||||||
@ap.send(:awesome, User).should == <<-EOS.strip
|
expect(@ap.send(:awesome, User)).to eq <<-EOS.strip
|
||||||
class User < ActiveRecord::Base {
|
class User < ActiveRecord::Base {
|
||||||
:id => :integer,
|
:id => :integer,
|
||||||
:name => :string,
|
:name => :string,
|
||||||
|
@ -378,7 +378,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should print the class for non-direct subclasses of ActiveRecord::Base" do
|
it "should print the class for non-direct subclasses of ActiveRecord::Base" do
|
||||||
@ap.send(:awesome, SubUser).should == <<-EOS.strip
|
expect(@ap.send(:awesome, SubUser)).to eq <<-EOS.strip
|
||||||
class SubUser < User {
|
class SubUser < User {
|
||||||
:id => :integer,
|
:id => :integer,
|
||||||
:name => :string,
|
:name => :string,
|
||||||
|
@ -390,7 +390,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should print ActiveRecord::Base objects (ex. ancestors)" do
|
it "should print ActiveRecord::Base objects (ex. ancestors)" do
|
||||||
lambda { @ap.send(:awesome, User.ancestors) }.should_not raise_error
|
expect { @ap.send(:awesome, User.ancestors) }.not_to raise_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -405,22 +405,22 @@ EOS
|
||||||
|
|
||||||
if ActiveRecord::VERSION::STRING >= "3.2"
|
if ActiveRecord::VERSION::STRING >= "3.2"
|
||||||
if RUBY_VERSION >= "1.9"
|
if RUBY_VERSION >= "1.9"
|
||||||
out.should =~ /\sfirst\(\*args,\s&block\)\s+Class \(ActiveRecord::Querying\)/
|
expect(out).to match(/\sfirst\(\*args,\s&block\)\s+Class \(ActiveRecord::Querying\)/)
|
||||||
else
|
else
|
||||||
out.should =~ /\sfirst\(\*arg1\)\s+Class \(ActiveRecord::Querying\)/
|
expect(out).to match(/\sfirst\(\*arg1\)\s+Class \(ActiveRecord::Querying\)/)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
out.should =~ /\sfirst\(\*arg.*?\)\s+User \(ActiveRecord::Base\)/
|
expect(out).to match(/\sfirst\(\*arg.*?\)\s+User \(ActiveRecord::Base\)/)
|
||||||
end
|
end
|
||||||
|
|
||||||
out = @ap.send(:awesome, User.methods.grep(/primary_key/))
|
out = @ap.send(:awesome, User.methods.grep(/primary_key/))
|
||||||
out.should =~ /\sprimary_key\(.*?\)\s+User/
|
expect(out).to match(/\sprimary_key\(.*?\)\s+User/)
|
||||||
|
|
||||||
out = @ap.send(:awesome, User.methods.grep(/validate/))
|
out = @ap.send(:awesome, User.methods.grep(/validate/))
|
||||||
if ActiveRecord::VERSION::MAJOR < 3
|
if ActiveRecord::VERSION::MAJOR < 3
|
||||||
out.should =~ /\svalidate\(\*arg.*?\)\s+User \(ActiveRecord::Base\)/
|
expect(out).to match(/\svalidate\(\*arg.*?\)\s+User \(ActiveRecord::Base\)/)
|
||||||
else
|
else
|
||||||
out.should =~ /\svalidate\(\*arg.*?\)\s+Class \(ActiveModel::Validations::ClassMethods\)/
|
expect(out).to match(/\svalidate\(\*arg.*?\)\s+Class \(ActiveModel::Validations::ClassMethods\)/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,20 +13,20 @@ begin
|
||||||
it "should format ActiveSupport::TimeWithZone as regular Time" do
|
it "should format ActiveSupport::TimeWithZone as regular Time" do
|
||||||
Time.zone = 'Eastern Time (US & Canada)'
|
Time.zone = 'Eastern Time (US & Canada)'
|
||||||
time = Time.utc(2007, 2, 10, 20, 30, 45).in_time_zone
|
time = Time.utc(2007, 2, 10, 20, 30, 45).in_time_zone
|
||||||
@ap.send(:awesome, time).should == "\e[0;32mSat, 10 Feb 2007 15:30:45 EST -05:00\e[0m"
|
expect(@ap.send(:awesome, time)).to eq("\e[0;32mSat, 10 Feb 2007 15:30:45 EST -05:00\e[0m")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should format HashWithIndifferentAccess as regular Hash" do
|
it "should format HashWithIndifferentAccess as regular Hash" do
|
||||||
hash = HashWithIndifferentAccess.new({ :hello => "world" })
|
hash = HashWithIndifferentAccess.new({ :hello => "world" })
|
||||||
@ap.send(:awesome, hash).should == "{\n \"hello\"\e[0;37m => \e[0m\e[0;33m\"world\"\e[0m\n}"
|
expect(@ap.send(:awesome, hash)).to eq("{\n \"hello\"\e[0;37m => \e[0m\e[0;33m\"world\"\e[0m\n}")
|
||||||
end
|
end
|
||||||
|
|
||||||
# ActiveSupport sticks in instance variables to the date object. Make sure
|
# ActiveSupport sticks in instance variables to the date object. Make sure
|
||||||
# we ignore that and format Date instance as regular date.
|
# we ignore that and format Date instance as regular date.
|
||||||
it "should formate Date object as date" do
|
it "should formate Date object as date" do
|
||||||
date = Date.new(2003, 5, 26)
|
date = Date.new(2003, 5, 26)
|
||||||
date.ai(:plain => true).should == "Mon, 26 May 2003"
|
expect(date.ai(:plain => true)).to eq("Mon, 26 May 2003")
|
||||||
date.ai.should == "\e[0;32mMon, 26 May 2003\e[0m"
|
expect(date.ai).to eq("\e[0;32mMon, 26 May 2003\e[0m")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -45,11 +45,11 @@ begin
|
||||||
>
|
>
|
||||||
EOS
|
EOS
|
||||||
out.gsub!(/0x([a-f\d]+)/, "0x01234567")
|
out.gsub!(/0x([a-f\d]+)/, "0x01234567")
|
||||||
out.should == str
|
expect(out).to eq(str)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should print the class" do
|
it "should print the class" do
|
||||||
@ap.send(:awesome, MongoUser).should == <<-EOS.strip
|
expect(@ap.send(:awesome, MongoUser)).to eq <<-EOS.strip
|
||||||
class MongoUser < Object {
|
class MongoUser < Object {
|
||||||
"_id" => :object_id,
|
"_id" => :object_id,
|
||||||
"first_name" => :string,
|
"first_name" => :string,
|
||||||
|
@ -64,7 +64,7 @@ EOS
|
||||||
key :last_attribute
|
key :last_attribute
|
||||||
end
|
end
|
||||||
|
|
||||||
@ap.send(:awesome, Chamelion).should == <<-EOS.strip
|
expect(@ap.send(:awesome, Chamelion)).to eq <<-EOS.strip
|
||||||
class Chamelion < Object {
|
class Chamelion < Object {
|
||||||
"_id" => :object_id,
|
"_id" => :object_id,
|
||||||
"last_attribute" => :undefined
|
"last_attribute" => :undefined
|
||||||
|
@ -96,7 +96,7 @@ EOS
|
||||||
|
|
||||||
describe "with show associations turned off (default)" do
|
describe "with show associations turned off (default)" do
|
||||||
it "should render the class as normal" do
|
it "should render the class as normal" do
|
||||||
@ap.send(:awesome, Parent).should == <<-EOS.strip
|
expect(@ap.send(:awesome, Parent)).to eq <<-EOS.strip
|
||||||
class Parent < Object {
|
class Parent < Object {
|
||||||
"_id" => :object_id,
|
"_id" => :object_id,
|
||||||
"name" => :undefined
|
"name" => :undefined
|
||||||
|
@ -115,7 +115,7 @@ EOS
|
||||||
EOS
|
EOS
|
||||||
out.gsub!(/'([\w]+){23}'/, "'4d9183739a546f6806000001'")
|
out.gsub!(/'([\w]+){23}'/, "'4d9183739a546f6806000001'")
|
||||||
out.gsub!(/0x([a-f\d]+)/, "0x01234567")
|
out.gsub!(/0x([a-f\d]+)/, "0x01234567")
|
||||||
out.should == str
|
expect(out).to eq(str)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should render the class with associations shown" do
|
it "should render the class with associations shown" do
|
||||||
@ap.send(:awesome, Parent).should == <<-EOS.strip
|
expect(@ap.send(:awesome, Parent)).to eq <<-EOS.strip
|
||||||
class Parent < Object {
|
class Parent < Object {
|
||||||
"_id" => :object_id,
|
"_id" => :object_id,
|
||||||
"name" => :undefined,
|
"name" => :undefined,
|
||||||
|
@ -148,7 +148,7 @@ EOS
|
||||||
EOS
|
EOS
|
||||||
out.gsub!(/'([\w]+){23}'/, "'4d9183739a546f6806000001'")
|
out.gsub!(/'([\w]+){23}'/, "'4d9183739a546f6806000001'")
|
||||||
out.gsub!(/0x([a-f\d]+)/, "0x01234567")
|
out.gsub!(/0x([a-f\d]+)/, "0x01234567")
|
||||||
out.should == str
|
expect(out).to eq(str)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ EOS
|
||||||
EOS
|
EOS
|
||||||
out.gsub!(/'([\w]+){23}'/, "'4d9183739a546f6806000001'")
|
out.gsub!(/'([\w]+){23}'/, "'4d9183739a546f6806000001'")
|
||||||
out.gsub!(/0x([a-f\d]+)/, "0x01234567")
|
out.gsub!(/0x([a-f\d]+)/, "0x01234567")
|
||||||
out.should == str
|
expect(out).to eq(str)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -42,12 +42,12 @@ EOS
|
||||||
else
|
else
|
||||||
out.gsub!(/Id\('[^']+/, "Id('424242424242424242424242")
|
out.gsub!(/Id\('[^']+/, "Id('424242424242424242424242")
|
||||||
end
|
end
|
||||||
out.should == str
|
expect(out).to eq(str)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should print the class" do
|
it "should print the class" do
|
||||||
moped_or_not = defined?(::Moped) ? 'moped/' : ''
|
moped_or_not = defined?(::Moped) ? 'moped/' : ''
|
||||||
@ap.send(:awesome, MongoUser).should == <<-EOS.strip
|
expect(@ap.send(:awesome, MongoUser)).to eq <<-EOS.strip
|
||||||
class MongoUser < Object {
|
class MongoUser < Object {
|
||||||
:_id => :"#{moped_or_not}bson/object_id",
|
:_id => :"#{moped_or_not}bson/object_id",
|
||||||
:_type => :string,
|
:_type => :string,
|
||||||
|
@ -65,7 +65,7 @@ EOS
|
||||||
|
|
||||||
moped_or_not = defined?(::Moped) ? 'moped/' : ''
|
moped_or_not = defined?(::Moped) ? 'moped/' : ''
|
||||||
last_attribute = defined?(::Moped) ? 'object' : '"mongoid/fields/serializable/object"'
|
last_attribute = defined?(::Moped) ? 'object' : '"mongoid/fields/serializable/object"'
|
||||||
@ap.send(:awesome, Chamelion).should == <<-EOS.strip
|
expect(@ap.send(:awesome, Chamelion)).to eq <<-EOS.strip
|
||||||
class Chamelion < Object {
|
class Chamelion < Object {
|
||||||
:_id => :"#{moped_or_not}bson/object_id",
|
:_id => :"#{moped_or_not}bson/object_id",
|
||||||
:_type => :string,
|
:_type => :string,
|
||||||
|
|
|
@ -11,7 +11,7 @@ begin
|
||||||
|
|
||||||
it "should colorize tags" do
|
it "should colorize tags" do
|
||||||
xml = Nokogiri::XML('<html><body><h1></h1></body></html>')
|
xml = Nokogiri::XML('<html><body><h1></h1></body></html>')
|
||||||
xml.ai.should == <<-EOS
|
expect(xml.ai).to eq <<-EOS
|
||||||
<?xml version=\"1.0\"?>\e[1;32m
|
<?xml version=\"1.0\"?>\e[1;32m
|
||||||
\e[0m<\e[1;36mhtml\e[0m>\e[1;32m
|
\e[0m<\e[1;36mhtml\e[0m>\e[1;32m
|
||||||
\e[0m<\e[1;36mbody\e[0m>\e[1;32m
|
\e[0m<\e[1;36mbody\e[0m>\e[1;32m
|
||||||
|
@ -23,7 +23,7 @@ EOS
|
||||||
|
|
||||||
it "should colorize contents" do
|
it "should colorize contents" do
|
||||||
xml = Nokogiri::XML('<html><body><h1>Hello</h1></body></html>')
|
xml = Nokogiri::XML('<html><body><h1>Hello</h1></body></html>')
|
||||||
xml.ai.should == <<-EOS
|
expect(xml.ai).to eq <<-EOS
|
||||||
<?xml version=\"1.0\"?>\e[1;32m
|
<?xml version=\"1.0\"?>\e[1;32m
|
||||||
\e[0m<\e[1;36mhtml\e[0m>\e[1;32m
|
\e[0m<\e[1;36mhtml\e[0m>\e[1;32m
|
||||||
\e[0m<\e[1;36mbody\e[0m>\e[1;32m
|
\e[0m<\e[1;36mbody\e[0m>\e[1;32m
|
||||||
|
@ -35,7 +35,7 @@ EOS
|
||||||
|
|
||||||
it "should colorize class and id" do
|
it "should colorize class and id" do
|
||||||
xml = Nokogiri::XML('<html><body><h1><span id="hello" class="world"></span></h1></body></html>')
|
xml = Nokogiri::XML('<html><body><h1><span id="hello" class="world"></span></h1></body></html>')
|
||||||
xml.ai.should == <<-EOS
|
expect(xml.ai).to eq <<-EOS
|
||||||
<?xml version=\"1.0\"?>\e[1;32m
|
<?xml version=\"1.0\"?>\e[1;32m
|
||||||
\e[0m<\e[1;36mhtml\e[0m>\e[1;32m
|
\e[0m<\e[1;36mhtml\e[0m>\e[1;32m
|
||||||
\e[0m<\e[1;36mbody\e[0m>\e[1;32m
|
\e[0m<\e[1;36mbody\e[0m>\e[1;32m
|
||||||
|
|
|
@ -29,7 +29,7 @@ begin
|
||||||
user = RippleUser.new :_id => "12345", :first_name => "Al", :last_name => "Capone"
|
user = RippleUser.new :_id => "12345", :first_name => "Al", :last_name => "Capone"
|
||||||
out = @ap.send :awesome, user
|
out = @ap.send :awesome, user
|
||||||
|
|
||||||
out.should == <<-EOS.strip
|
expect(out).to eq <<-EOS.strip
|
||||||
#<RippleUser:12345> {
|
#<RippleUser:12345> {
|
||||||
:_id => "12345",
|
:_id => "12345",
|
||||||
:first_name => "Al",
|
:first_name => "Al",
|
||||||
|
@ -39,7 +39,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should print the class" do
|
it "should print the class" do
|
||||||
@ap.send(:awesome, RippleUser).should == <<-EOS.strip
|
expect(@ap.send(:awesome, RippleUser)).to eq <<-EOS.strip
|
||||||
class RippleUser < Object {
|
class RippleUser < Object {
|
||||||
:_id => :string,
|
:_id => :string,
|
||||||
:_type => :string,
|
:_type => :string,
|
||||||
|
|
|
@ -14,11 +14,11 @@ describe "AwesomePrint" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "empty array" do
|
it "empty array" do
|
||||||
[].ai.should == "[]"
|
expect([].ai).to eq("[]")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain multiline" do
|
it "plain multiline" do
|
||||||
@arr.ai(:plain => true).should == <<-EOS.strip
|
expect(@arr.ai(:plain => true)).to eq <<-EOS.strip
|
||||||
[
|
[
|
||||||
[0] 1,
|
[0] 1,
|
||||||
[1] :two,
|
[1] :two,
|
||||||
|
@ -35,7 +35,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain multiline without index" do
|
it "plain multiline without index" do
|
||||||
@arr.ai(:plain => true, :index => false).should == <<-EOS.strip
|
expect(@arr.ai(:plain => true, :index => false)).to eq <<-EOS.strip
|
||||||
[
|
[
|
||||||
1,
|
1,
|
||||||
:two,
|
:two,
|
||||||
|
@ -52,7 +52,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain multiline indented" do
|
it "plain multiline indented" do
|
||||||
@arr.ai(:plain => true, :indent => 2).should == <<-EOS.strip
|
expect(@arr.ai(:plain => true, :indent => 2)).to eq <<-EOS.strip
|
||||||
[
|
[
|
||||||
[0] 1,
|
[0] 1,
|
||||||
[1] :two,
|
[1] :two,
|
||||||
|
@ -69,7 +69,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain multiline indented without index" do
|
it "plain multiline indented without index" do
|
||||||
@arr.ai(:plain => true, :indent => 2, :index => false).should == <<-EOS.strip
|
expect(@arr.ai(:plain => true, :indent => 2, :index => false)).to eq <<-EOS.strip
|
||||||
[
|
[
|
||||||
1,
|
1,
|
||||||
:two,
|
:two,
|
||||||
|
@ -86,11 +86,11 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain single line" do
|
it "plain single line" do
|
||||||
@arr.ai(:plain => true, :multiline => false).should == '[ 1, :two, "three", [ nil, [ true, false ] ] ]'
|
expect(@arr.ai(:plain => true, :multiline => false)).to eq('[ 1, :two, "three", [ nil, [ true, false ] ] ]')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "colored multiline (default)" do
|
it "colored multiline (default)" do
|
||||||
@arr.ai.should == <<-EOS.strip
|
expect(@arr.ai).to eq <<-EOS.strip
|
||||||
[
|
[
|
||||||
\e[1;37m[0] \e[0m\e[1;34m1\e[0m,
|
\e[1;37m[0] \e[0m\e[1;34m1\e[0m,
|
||||||
\e[1;37m[1] \e[0m\e[0;36m:two\e[0m,
|
\e[1;37m[1] \e[0m\e[0;36m:two\e[0m,
|
||||||
|
@ -107,7 +107,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "colored multiline indented" do
|
it "colored multiline indented" do
|
||||||
@arr.ai(:indent => 8).should == <<-EOS.strip
|
expect(@arr.ai(:indent => 8)).to eq <<-EOS.strip
|
||||||
[
|
[
|
||||||
\e[1;37m[0] \e[0m\e[1;34m1\e[0m,
|
\e[1;37m[0] \e[0m\e[1;34m1\e[0m,
|
||||||
\e[1;37m[1] \e[0m\e[0;36m:two\e[0m,
|
\e[1;37m[1] \e[0m\e[0;36m:two\e[0m,
|
||||||
|
@ -124,7 +124,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "colored single line" do
|
it "colored single line" do
|
||||||
@arr.ai(:multiline => false).should == "[ \e[1;34m1\e[0m, \e[0;36m:two\e[0m, \e[0;33m\"three\"\e[0m, [ \e[1;31mnil\e[0m, [ \e[1;32mtrue\e[0m, \e[1;31mfalse\e[0m ] ] ]"
|
expect(@arr.ai(:multiline => false)).to eq("[ \e[1;34m1\e[0m, \e[0;36m:two\e[0m, \e[0;33m\"three\"\e[0m, [ \e[1;31mnil\e[0m, [ \e[1;32mtrue\e[0m, \e[1;31mfalse\e[0m ] ] ]")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain multiline" do
|
it "plain multiline" do
|
||||||
@arr.ai(:plain => true).should == <<-EOS.strip
|
expect(@arr.ai(:plain => true)).to eq <<-EOS.strip
|
||||||
[
|
[
|
||||||
[0] 1,
|
[0] 1,
|
||||||
[1] 2,
|
[1] 2,
|
||||||
|
@ -146,7 +146,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain multiline without index" do
|
it "plain multiline without index" do
|
||||||
@arr.ai(:plain => true, :index => false).should == <<-EOS.strip
|
expect(@arr.ai(:plain => true, :index => false)).to eq <<-EOS.strip
|
||||||
[
|
[
|
||||||
1,
|
1,
|
||||||
2,
|
2,
|
||||||
|
@ -156,7 +156,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain single line" do
|
it "plain single line" do
|
||||||
@arr.ai(:plain => true, :multiline => false).should == "[ 1, 2, [...] ]"
|
expect(@arr.ai(:plain => true, :multiline => false)).to eq("[ 1, 2, [...] ]")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain limited output large" do
|
it "plain limited output large" do
|
||||||
@arr.ai(:plain => true, :limit => true).should == <<-EOS.strip
|
expect(@arr.ai(:plain => true, :limit => true)).to eq <<-EOS.strip
|
||||||
[
|
[
|
||||||
[ 0] 1,
|
[ 0] 1,
|
||||||
[ 1] 2,
|
[ 1] 2,
|
||||||
|
@ -182,7 +182,7 @@ EOS
|
||||||
|
|
||||||
it "plain limited output small" do
|
it "plain limited output small" do
|
||||||
@arr = @arr[0..3]
|
@arr = @arr[0..3]
|
||||||
@arr.ai(:plain => true, :limit => true).should == <<-EOS.strip
|
expect(@arr.ai(:plain => true, :limit => true)).to eq <<-EOS.strip
|
||||||
[
|
[
|
||||||
[0] 1,
|
[0] 1,
|
||||||
[1] 2,
|
[1] 2,
|
||||||
|
@ -193,7 +193,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain limited output with 10 lines" do
|
it "plain limited output with 10 lines" do
|
||||||
@arr.ai(:plain => true, :limit => 10).should == <<-EOS.strip
|
expect(@arr.ai(:plain => true, :limit => 10)).to eq <<-EOS.strip
|
||||||
[
|
[
|
||||||
[ 0] 1,
|
[ 0] 1,
|
||||||
[ 1] 2,
|
[ 1] 2,
|
||||||
|
@ -210,7 +210,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain limited output with 11 lines" do
|
it "plain limited output with 11 lines" do
|
||||||
@arr.ai(:plain => true, :limit => 11).should == <<-EOS.strip
|
expect(@arr.ai(:plain => true, :limit => 11)).to eq <<-EOS.strip
|
||||||
[
|
[
|
||||||
[ 0] 1,
|
[ 0] 1,
|
||||||
[ 1] 2,
|
[ 1] 2,
|
||||||
|
@ -235,7 +235,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain limited output" do
|
it "plain limited output" do
|
||||||
@hash.ai(:sort_keys => true, :plain => true, :limit => true).should == <<-EOS.strip
|
expect(@hash.ai(:sort_keys => true, :plain => true, :limit => true)).to eq <<-EOS.strip
|
||||||
{
|
{
|
||||||
"a" => :a,
|
"a" => :a,
|
||||||
"b" => :b,
|
"b" => :b,
|
||||||
|
@ -256,11 +256,11 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "empty hash" do
|
it "empty hash" do
|
||||||
{}.ai.should == "{}"
|
expect({}.ai).to eq("{}")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain multiline" do
|
it "plain multiline" do
|
||||||
@hash.ai(:plain => true).should == <<-EOS.strip
|
expect(@hash.ai(:plain => true)).to eq <<-EOS.strip
|
||||||
{
|
{
|
||||||
1 => {
|
1 => {
|
||||||
:sym => {
|
:sym => {
|
||||||
|
@ -276,7 +276,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain multiline indented" do
|
it "plain multiline indented" do
|
||||||
@hash.ai(:plain => true, :indent => 1).should == <<-EOS.strip
|
expect(@hash.ai(:plain => true, :indent => 1)).to eq <<-EOS.strip
|
||||||
{
|
{
|
||||||
1 => {
|
1 => {
|
||||||
:sym => {
|
:sym => {
|
||||||
|
@ -292,11 +292,11 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain single line" do
|
it "plain single line" do
|
||||||
@hash.ai(:plain => true, :multiline => false).should == '{ 1 => { :sym => { "str" => { [ 1, 2, 3 ] => { { :k => :v } => Hash < Object } } } } }'
|
expect(@hash.ai(:plain => true, :multiline => false)).to eq('{ 1 => { :sym => { "str" => { [ 1, 2, 3 ] => { { :k => :v } => Hash < Object } } } } }')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "colored multiline (default)" do
|
it "colored multiline (default)" do
|
||||||
@hash.ai.should == <<-EOS.strip
|
expect(@hash.ai).to eq <<-EOS.strip
|
||||||
{
|
{
|
||||||
1\e[0;37m => \e[0m{
|
1\e[0;37m => \e[0m{
|
||||||
:sym\e[0;37m => \e[0m{
|
:sym\e[0;37m => \e[0m{
|
||||||
|
@ -312,7 +312,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "colored multiline indented" do
|
it "colored multiline indented" do
|
||||||
@hash.ai(:indent => 2).should == <<-EOS.strip
|
expect(@hash.ai(:indent => 2)).to eq <<-EOS.strip
|
||||||
{
|
{
|
||||||
1\e[0;37m => \e[0m{
|
1\e[0;37m => \e[0m{
|
||||||
:sym\e[0;37m => \e[0m{
|
:sym\e[0;37m => \e[0m{
|
||||||
|
@ -328,7 +328,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "colored single line" do
|
it "colored single line" do
|
||||||
@hash.ai(:multiline => false).should == "{ 1\e[0;37m => \e[0m{ :sym\e[0;37m => \e[0m{ \"str\"\e[0;37m => \e[0m{ [ 1, 2, 3 ]\e[0;37m => \e[0m{ { :k => :v }\e[0;37m => \e[0m\e[1;33mHash < Object\e[0m } } } } }"
|
expect(@hash.ai(:multiline => false)).to eq("{ 1\e[0;37m => \e[0m{ :sym\e[0;37m => \e[0m{ \"str\"\e[0;37m => \e[0m{ [ 1, 2, 3 ]\e[0;37m => \e[0m{ { :k => :v }\e[0;37m => \e[0m\e[1;33mHash < Object\e[0m } } } } }")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -341,7 +341,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain multiline" do
|
it "plain multiline" do
|
||||||
@hash.ai(:plain => true).should == <<-EOS.strip
|
expect(@hash.ai(:plain => true)).to eq <<-EOS.strip
|
||||||
{
|
{
|
||||||
:a => {...}
|
:a => {...}
|
||||||
}
|
}
|
||||||
|
@ -349,7 +349,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain single line" do
|
it "plain single line" do
|
||||||
@hash.ai(:plain => true, :multiline => false).should == '{ :a => {...} }'
|
expect(@hash.ai(:plain => true, :multiline => false)).to eq('{ :a => {...} }')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -362,13 +362,13 @@ EOS
|
||||||
it "plain multiline" do
|
it "plain multiline" do
|
||||||
out = @hash.ai(:plain => true)
|
out = @hash.ai(:plain => true)
|
||||||
if RUBY_VERSION.to_f < 1.9 # Order of @hash keys is not guaranteed.
|
if RUBY_VERSION.to_f < 1.9 # Order of @hash keys is not guaranteed.
|
||||||
out.should =~ /^\{[^\}]+\}/m
|
expect(out).to match(/^\{[^\}]+\}/m)
|
||||||
out.should =~ / "b" => "b",?/
|
expect(out).to match(/ "b" => "b",?/)
|
||||||
out.should =~ / :a => "a",?/
|
expect(out).to match(/ :a => "a",?/)
|
||||||
out.should =~ / :z => "z",?/
|
expect(out).to match(/ :z => "z",?/)
|
||||||
out.should =~ / "alpha" => "alpha",?$/
|
expect(out).to match(/ "alpha" => "alpha",?$/)
|
||||||
else
|
else
|
||||||
out.should == <<-EOS.strip
|
expect(out).to eq <<-EOS.strip
|
||||||
{
|
{
|
||||||
"b" => "b",
|
"b" => "b",
|
||||||
:a => "a",
|
:a => "a",
|
||||||
|
@ -380,7 +380,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain multiline with sorted keys" do
|
it "plain multiline with sorted keys" do
|
||||||
@hash.ai(:plain => true, :sort_keys => true).should == <<-EOS.strip
|
expect(@hash.ai(:plain => true, :sort_keys => true)).to eq <<-EOS.strip
|
||||||
{
|
{
|
||||||
:a => "a",
|
:a => "a",
|
||||||
"alpha" => "alpha",
|
"alpha" => "alpha",
|
||||||
|
@ -401,7 +401,7 @@ EOS
|
||||||
it "hash keys must be left aligned" do
|
it "hash keys must be left aligned" do
|
||||||
hash = { [0, 0, 255] => :yellow, :red => "rgb(255, 0, 0)", "magenta" => "rgb(255, 0, 255)" }
|
hash = { [0, 0, 255] => :yellow, :red => "rgb(255, 0, 0)", "magenta" => "rgb(255, 0, 255)" }
|
||||||
out = hash.ai(:plain => true, :indent => -4, :sort_keys => true)
|
out = hash.ai(:plain => true, :indent => -4, :sort_keys => true)
|
||||||
out.should == <<-EOS.strip
|
expect(out).to eq <<-EOS.strip
|
||||||
{
|
{
|
||||||
[ 0, 0, 255 ] => :yellow,
|
[ 0, 0, 255 ] => :yellow,
|
||||||
"magenta" => "rgb(255, 0, 255)",
|
"magenta" => "rgb(255, 0, 255)",
|
||||||
|
@ -413,7 +413,7 @@ EOS
|
||||||
it "nested hash keys should be indented (array of hashes)" do
|
it "nested hash keys should be indented (array of hashes)" do
|
||||||
arr = [ { :a => 1, :bb => 22, :ccc => 333}, { 1 => :a, 22 => :bb, 333 => :ccc} ]
|
arr = [ { :a => 1, :bb => 22, :ccc => 333}, { 1 => :a, 22 => :bb, 333 => :ccc} ]
|
||||||
out = arr.ai(:plain => true, :indent => -4, :sort_keys => true)
|
out = arr.ai(:plain => true, :indent => -4, :sort_keys => true)
|
||||||
out.should == <<-EOS.strip
|
expect(out).to eq <<-EOS.strip
|
||||||
[
|
[
|
||||||
[0] {
|
[0] {
|
||||||
:a => 1,
|
:a => 1,
|
||||||
|
@ -432,7 +432,7 @@ EOS
|
||||||
it "nested hash keys should be indented (hash of hashes)" do
|
it "nested hash keys should be indented (hash of hashes)" do
|
||||||
arr = { :first => { :a => 1, :bb => 22, :ccc => 333}, :second => { 1 => :a, 22 => :bb, 333 => :ccc} }
|
arr = { :first => { :a => 1, :bb => 22, :ccc => 333}, :second => { 1 => :a, 22 => :bb, 333 => :ccc} }
|
||||||
out = arr.ai(:plain => true, :indent => -4, :sort_keys => true)
|
out = arr.ai(:plain => true, :indent => -4, :sort_keys => true)
|
||||||
out.should == <<-EOS.strip
|
expect(out).to eq <<-EOS.strip
|
||||||
{
|
{
|
||||||
:first => {
|
:first => {
|
||||||
:a => 1,
|
:a => 1,
|
||||||
|
@ -452,11 +452,11 @@ EOS
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
describe "Class" do
|
describe "Class" do
|
||||||
it "shoud show superclass (plain)" do
|
it "shoud show superclass (plain)" do
|
||||||
self.class.ai(:plain => true).should == "#{self.class} < #{self.class.superclass}"
|
expect(self.class.ai(:plain => true)).to eq("#{self.class} < #{self.class.superclass}")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "shoud show superclass (color)" do
|
it "shoud show superclass (color)" do
|
||||||
self.class.ai.should == "#{self.class} < #{self.class.superclass}".yellow
|
expect(self.class.ai).to eq("#{self.class} < #{self.class.superclass}".yellow)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -464,7 +464,7 @@ EOS
|
||||||
describe "File" do
|
describe "File" do
|
||||||
it "should display a file (plain)" do
|
it "should display a file (plain)" do
|
||||||
File.open(__FILE__, "r") do |f|
|
File.open(__FILE__, "r") do |f|
|
||||||
f.ai(:plain => true).should == "#{f.inspect}\n" << `ls -alF #{f.path}`.chop
|
expect(f.ai(:plain => true)).to eq("#{f.inspect}\n" << `ls -alF #{f.path}`.chop)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -473,7 +473,7 @@ EOS
|
||||||
describe "Dir" do
|
describe "Dir" do
|
||||||
it "should display a direcory (plain)" do
|
it "should display a direcory (plain)" do
|
||||||
Dir.open(File.dirname(__FILE__)) do |d|
|
Dir.open(File.dirname(__FILE__)) do |d|
|
||||||
d.ai(:plain => true).should == "#{d.inspect}\n" << `ls -alF #{d.path}`.chop
|
expect(d.ai(:plain => true)).to eq("#{d.inspect}\n" << `ls -alF #{d.path}`.chop)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -482,7 +482,7 @@ EOS
|
||||||
describe "BigDecimal and Rational" do
|
describe "BigDecimal and Rational" do
|
||||||
it "should present BigDecimal object with arbitrary precision" do
|
it "should present BigDecimal object with arbitrary precision" do
|
||||||
big = BigDecimal("201020102010201020102010201020102010.4")
|
big = BigDecimal("201020102010201020102010201020102010.4")
|
||||||
big.ai(:plain => true).should == "201020102010201020102010201020102010.4"
|
expect(big.ai(:plain => true)).to eq("201020102010201020102010201020102010.4")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should present Rational object with arbitrary precision" do
|
it "should present Rational object with arbitrary precision" do
|
||||||
|
@ -494,9 +494,9 @@ EOS
|
||||||
# http://www.ruby-forum.com/topic/189397
|
# http://www.ruby-forum.com/topic/189397
|
||||||
#
|
#
|
||||||
if RUBY_VERSION < "1.9"
|
if RUBY_VERSION < "1.9"
|
||||||
out.should == "100510051005100510051005100510051005"
|
expect(out).to eq("100510051005100510051005100510051005")
|
||||||
else
|
else
|
||||||
out.should == "100510051005100510051005100510051005/1"
|
expect(out).to eq("100510051005100510051005100510051005/1")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -507,8 +507,8 @@ EOS
|
||||||
ap = AwesomePrint::Inspector.new
|
ap = AwesomePrint::Inspector.new
|
||||||
ap.send(:merge_options!, { :color => { :array => :black }, :indent => 0 })
|
ap.send(:merge_options!, { :color => { :array => :black }, :indent => 0 })
|
||||||
options = ap.instance_variable_get("@options")
|
options = ap.instance_variable_get("@options")
|
||||||
options[:color][:array].should == :black
|
expect(options[:color][:array]).to eq(:black)
|
||||||
options[:indent].should == 0
|
expect(options[:indent]).to eq(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -520,40 +520,40 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "empty set" do
|
it "empty set" do
|
||||||
Set.new.ai.should == [].ai
|
expect(Set.new.ai).to eq([].ai)
|
||||||
end
|
end
|
||||||
|
|
||||||
if RUBY_VERSION > "1.9"
|
if RUBY_VERSION > "1.9"
|
||||||
it "plain multiline" do
|
it "plain multiline" do
|
||||||
@set.ai(:plain => true).should == @arr.ai(:plain => true)
|
expect(@set.ai(:plain => true)).to eq(@arr.ai(:plain => true))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain multiline indented" do
|
it "plain multiline indented" do
|
||||||
@set.ai(:plain => true, :indent => 1).should == @arr.ai(:plain => true, :indent => 1)
|
expect(@set.ai(:plain => true, :indent => 1)).to eq(@arr.ai(:plain => true, :indent => 1))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain single line" do
|
it "plain single line" do
|
||||||
@set.ai(:plain => true, :multiline => false).should == @arr.ai(:plain => true, :multiline => false)
|
expect(@set.ai(:plain => true, :multiline => false)).to eq(@arr.ai(:plain => true, :multiline => false))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "colored multiline (default)" do
|
it "colored multiline (default)" do
|
||||||
@set.ai.should == @arr.ai
|
expect(@set.ai).to eq(@arr.ai)
|
||||||
end
|
end
|
||||||
else # Prior to Ruby 1.9 the order of set values is unpredicatble.
|
else # Prior to Ruby 1.9 the order of set values is unpredicatble.
|
||||||
it "plain multiline" do
|
it "plain multiline" do
|
||||||
@set.sort_by{ |x| x.to_s }.ai(:plain => true).should == @arr.sort_by{ |x| x.to_s }.ai(:plain => true)
|
expect(@set.sort_by{ |x| x.to_s }.ai(:plain => true)).to eq(@arr.sort_by{ |x| x.to_s }.ai(:plain => true))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain multiline indented" do
|
it "plain multiline indented" do
|
||||||
@set.sort_by{ |x| x.to_s }.ai(:plain => true, :indent => 1).should == @arr.sort_by{ |x| x.to_s }.ai(:plain => true, :indent => 1)
|
expect(@set.sort_by{ |x| x.to_s }.ai(:plain => true, :indent => 1)).to eq(@arr.sort_by{ |x| x.to_s }.ai(:plain => true, :indent => 1))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain single line" do
|
it "plain single line" do
|
||||||
@set.sort_by{ |x| x.to_s }.ai(:plain => true, :multiline => false).should == @arr.sort_by{ |x| x.to_s }.ai(:plain => true, :multiline => false)
|
expect(@set.sort_by{ |x| x.to_s }.ai(:plain => true, :multiline => false)).to eq(@arr.sort_by{ |x| x.to_s }.ai(:plain => true, :multiline => false))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "colored multiline (default)" do
|
it "colored multiline (default)" do
|
||||||
@set.sort_by{ |x| x.to_s }.ai.should == @arr.sort_by{ |x| x.to_s }.ai
|
expect(@set.sort_by{ |x| x.to_s }.ai).to eq(@arr.sort_by{ |x| x.to_s }.ai)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -571,7 +571,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "empty struct" do
|
it "empty struct" do
|
||||||
Struct.new("EmptyStruct").ai.should == "\e[1;33mStruct::EmptyStruct < Struct\e[0m"
|
expect(Struct.new("EmptyStruct").ai).to eq("\e[1;33mStruct::EmptyStruct < Struct\e[0m")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain multiline" do
|
it "plain multiline" do
|
||||||
|
@ -587,7 +587,7 @@ EOS
|
||||||
:address => "1313 Mockingbird Lane"
|
:address => "1313 Mockingbird Lane"
|
||||||
}
|
}
|
||||||
EOS
|
EOS
|
||||||
@struct.ai(:plain => true).should satisfy { |match| match == s1 || match == s2 }
|
expect(@struct.ai(:plain => true)).to satisfy { |match| match == s1 || match == s2 }
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain multiline indented" do
|
it "plain multiline indented" do
|
||||||
|
@ -603,13 +603,13 @@ EOS
|
||||||
:address => "1313 Mockingbird Lane"
|
:address => "1313 Mockingbird Lane"
|
||||||
}
|
}
|
||||||
EOS
|
EOS
|
||||||
@struct.ai(:plain => true, :indent => 1).should satisfy { |match| match == s1 || match == s2 }
|
expect(@struct.ai(:plain => true, :indent => 1)).to satisfy { |match| match == s1 || match == s2 }
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain single line" do
|
it "plain single line" do
|
||||||
s1 = "{ :address => \"1313 Mockingbird Lane\", :name => \"Herman Munster\" }"
|
s1 = "{ :address => \"1313 Mockingbird Lane\", :name => \"Herman Munster\" }"
|
||||||
s2 = "{ :name => \"Herman Munster\", :address => \"1313 Mockingbird Lane\" }"
|
s2 = "{ :name => \"Herman Munster\", :address => \"1313 Mockingbird Lane\" }"
|
||||||
@struct.ai(:plain => true, :multiline => false).should satisfy { |match| match == s1 || match == s2 }
|
expect(@struct.ai(:plain => true, :multiline => false)).to satisfy { |match| match == s1 || match == s2 }
|
||||||
end
|
end
|
||||||
|
|
||||||
it "colored multiline (default)" do
|
it "colored multiline (default)" do
|
||||||
|
@ -625,7 +625,7 @@ EOS
|
||||||
:address\e[0;37m => \e[0m\e[0;33m\"1313 Mockingbird Lane\"\e[0m
|
:address\e[0;37m => \e[0m\e[0;33m\"1313 Mockingbird Lane\"\e[0m
|
||||||
}
|
}
|
||||||
EOS
|
EOS
|
||||||
@struct.ai.should satisfy { |match| match == s1 || match == s2 }
|
expect(@struct.ai).to satisfy { |match| match == s1 || match == s2 }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -639,7 +639,7 @@ EOS
|
||||||
class My < Array; end
|
class My < Array; end
|
||||||
|
|
||||||
my = My.new([ 1, :two, "three", [ nil, [ true, false ] ] ])
|
my = My.new([ 1, :two, "three", [ nil, [ true, false ] ] ])
|
||||||
my.ai(:plain => true).should == <<-EOS.strip
|
expect(my.ai(:plain => true)).to eq <<-EOS.strip
|
||||||
[
|
[
|
||||||
[0] 1,
|
[0] 1,
|
||||||
[1] :two,
|
[1] :two,
|
||||||
|
@ -659,7 +659,7 @@ EOS
|
||||||
class My < Hash; end
|
class My < Hash; end
|
||||||
|
|
||||||
my = My[ { 1 => { :sym => { "str" => { [1, 2, 3] => { { :k => :v } => Hash } } } } } ]
|
my = My[ { 1 => { :sym => { "str" => { [1, 2, 3] => { { :k => :v } => Hash } } } } } ]
|
||||||
my.ai(:plain => true).should == <<-EOS.strip
|
expect(my.ai(:plain => true)).to eq <<-EOS.strip
|
||||||
{
|
{
|
||||||
1 => {
|
1 => {
|
||||||
:sym => {
|
:sym => {
|
||||||
|
@ -678,7 +678,7 @@ EOS
|
||||||
class My < File; end
|
class My < File; end
|
||||||
|
|
||||||
my = File.new('/dev/null') rescue File.new('nul')
|
my = File.new('/dev/null') rescue File.new('nul')
|
||||||
my.ai(:plain => true).should == "#{my.inspect}\n" << `ls -alF #{my.path}`.chop
|
expect(my.ai(:plain => true)).to eq("#{my.inspect}\n" << `ls -alF #{my.path}`.chop)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "inherited from Dir should be displayed as Dir" do
|
it "inherited from Dir should be displayed as Dir" do
|
||||||
|
@ -686,7 +686,7 @@ EOS
|
||||||
|
|
||||||
require 'tmpdir'
|
require 'tmpdir'
|
||||||
my = My.new(Dir.tmpdir)
|
my = My.new(Dir.tmpdir)
|
||||||
my.ai(:plain => true).should == "#{my.inspect}\n" << `ls -alF #{my.path}`.chop
|
expect(my.ai(:plain => true)).to eq("#{my.inspect}\n" << `ls -alF #{my.path}`.chop)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should handle a class that defines its own #send method" do
|
it "should handle a class that defines its own #send method" do
|
||||||
|
@ -695,7 +695,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
my = My.new
|
my = My.new
|
||||||
my.methods.ai(:plain => true).should_not raise_error(ArgumentError)
|
expect(my.methods.ai(:plain => true)).not_to raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should handle a class defines its own #method method (ex. request.method)" do
|
it "should handle a class defines its own #method method (ex. request.method)" do
|
||||||
|
@ -706,7 +706,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
my = My.new
|
my = My.new
|
||||||
my.methods.ai(:plain => true).should_not raise_error(ArgumentError)
|
expect(my.methods.ai(:plain => true)).not_to raise_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,52 +11,52 @@ describe "Single method" do
|
||||||
|
|
||||||
it "plain: should handle a method with no arguments" do
|
it "plain: should handle a method with no arguments" do
|
||||||
method = ''.method(:upcase)
|
method = ''.method(:upcase)
|
||||||
method.ai(:plain => true).should == 'String#upcase()'
|
expect(method.ai(:plain => true)).to eq('String#upcase()')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "color: should handle a method with no arguments" do
|
it "color: should handle a method with no arguments" do
|
||||||
method = ''.method(:upcase)
|
method = ''.method(:upcase)
|
||||||
method.ai.should == "\e[1;33mString\e[0m#\e[0;35mupcase\e[0m\e[0;37m()\e[0m"
|
expect(method.ai).to eq("\e[1;33mString\e[0m#\e[0;35mupcase\e[0m\e[0;37m()\e[0m")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain: should handle a method with one argument" do
|
it "plain: should handle a method with one argument" do
|
||||||
method = ''.method(:include?)
|
method = ''.method(:include?)
|
||||||
method.ai(:plain => true).should == 'String#include?(arg1)'
|
expect(method.ai(:plain => true)).to eq('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(:include?)
|
method = ''.method(:include?)
|
||||||
method.ai.should == "\e[1;33mString\e[0m#\e[0;35minclude?\e[0m\e[0;37m(arg1)\e[0m"
|
expect(method.ai).to eq("\e[1;33mString\e[0m#\e[0;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
|
||||||
method = ''.method(:tr)
|
method = ''.method(:tr)
|
||||||
method.ai(:plain => true).should == 'String#tr(arg1, arg2)'
|
expect(method.ai(:plain => true)).to eq('String#tr(arg1, arg2)')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "color: should handle a method with two arguments" do
|
it "color: should handle a method with two arguments" do
|
||||||
method = ''.method(:tr)
|
method = ''.method(:tr)
|
||||||
method.ai.should == "\e[1;33mString\e[0m#\e[0;35mtr\e[0m\e[0;37m(arg1, arg2)\e[0m"
|
expect(method.ai).to eq("\e[1;33mString\e[0m#\e[0;35mtr\e[0m\e[0;37m(arg1, arg2)\e[0m")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain: should handle a method with multiple arguments" do
|
it "plain: should handle a method with multiple arguments" do
|
||||||
method = ''.method(:split)
|
method = ''.method(:split)
|
||||||
method.ai(:plain => true).should == 'String#split(*arg1)'
|
expect(method.ai(:plain => true)).to eq('String#split(*arg1)')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "color: should handle a method with multiple arguments" do
|
it "color: should handle a method with multiple arguments" do
|
||||||
method = ''.method(:split)
|
method = ''.method(:split)
|
||||||
method.ai.should == "\e[1;33mString\e[0m#\e[0;35msplit\e[0m\e[0;37m(*arg1)\e[0m"
|
expect(method.ai).to eq("\e[1;33mString\e[0m#\e[0;35msplit\e[0m\e[0;37m(*arg1)\e[0m")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "plain: should handle a method defined in mixin" do
|
it "plain: should handle a method defined in mixin" do
|
||||||
method = ''.method(:is_a?)
|
method = ''.method(:is_a?)
|
||||||
method.ai(:plain => true).should == 'String (Kernel)#is_a?(arg1)'
|
expect(method.ai(:plain => true)).to eq('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(:is_a?)
|
method = ''.method(:is_a?)
|
||||||
method.ai.should == "\e[1;33mString (Kernel)\e[0m#\e[0;35mis_a?\e[0m\e[0;37m(arg1)\e[0m"
|
expect(method.ai).to eq("\e[1;33mString (Kernel)\e[0m#\e[0;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
|
||||||
|
@ -64,7 +64,7 @@ describe "Single method" do
|
||||||
def world; end
|
def world; end
|
||||||
end
|
end
|
||||||
method = Hello.instance_method(:world)
|
method = Hello.instance_method(:world)
|
||||||
method.ai(:plain => true).should == 'Hello (unbound)#world()'
|
expect(method.ai(:plain => true)).to eq('Hello (unbound)#world()')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "color: should handle an unbound method" do
|
it "color: should handle an unbound method" do
|
||||||
|
@ -73,9 +73,9 @@ describe "Single method" do
|
||||||
end
|
end
|
||||||
method = Hello.instance_method(:world)
|
method = Hello.instance_method(:world)
|
||||||
if RUBY_VERSION < '1.9.2'
|
if RUBY_VERSION < '1.9.2'
|
||||||
method.ai.should == "\e[1;33mHello (unbound)\e[0m#\e[0;35mworld\e[0m\e[0;37m(arg1, arg2)\e[0m"
|
expect(method.ai).to eq("\e[1;33mHello (unbound)\e[0m#\e[0;35mworld\e[0m\e[0;37m(arg1, arg2)\e[0m")
|
||||||
else
|
else
|
||||||
method.ai.should == "\e[1;33mHello (unbound)\e[0m#\e[0;35mworld\e[0m\e[0;37m(a, b)\e[0m"
|
expect(method.ai).to eq("\e[1;33mHello (unbound)\e[0m#\e[0;35mworld\e[0m\e[0;37m(a, b)\e[0m")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -92,36 +92,36 @@ describe "Object methods" do
|
||||||
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).split("\n").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\)$/
|
expect(out).to match(/^\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).split("\n").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\)$/
|
expect(out).to match(/^\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).split("\n").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\)$/
|
expect(out).to match(/^\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).split("\n").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\)$/
|
expect(out).to match(/^\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).split("\n").grep(/sleep/).first
|
out = nil.private_methods.ai(:plain => true).split("\n").grep(/sleep/).first
|
||||||
out.should =~ /^\s+\[\s*\d+\]\s+sleep\(\*arg1\)\s+NilClass \(Kernel\)$/
|
expect(out).to match(/^\s+\[\s*\d+\]\s+sleep\(\*arg1\)\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).split("\n").grep(/sleep/).first
|
out = nil.private_methods.ai(:plain => true, :index => false).split("\n").grep(/sleep/).first
|
||||||
out.should =~ /^\s+sleep\(\*arg1\)\s+NilClass \(Kernel\)$/
|
expect(out).to match(/^\s+sleep\(\*arg1\)\s+NilClass \(Kernel\)$/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ describe "Object methods" do
|
||||||
def m1; end
|
def m1; end
|
||||||
def m2; end
|
def m2; end
|
||||||
end
|
end
|
||||||
Hello.new.protected_methods.ai(:plain => true).should == "[\n [0] m1() Hello\n [1] m2() Hello\n]"
|
expect(Hello.new.protected_methods.ai(:plain => true)).to eq("[\n [0] m1() Hello\n [1] m2() Hello\n]")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "no index: should handle object.protected_methods" do
|
it "no index: should handle object.protected_methods" do
|
||||||
|
@ -141,9 +141,9 @@ describe "Object methods" do
|
||||||
def m3(a,b); end
|
def m3(a,b); end
|
||||||
end
|
end
|
||||||
if RUBY_VERSION < '1.9.2'
|
if RUBY_VERSION < '1.9.2'
|
||||||
Hello.new.protected_methods.ai(:plain => true, :index => false).should == "[\n m3(arg1, arg2) Hello\n]"
|
expect(Hello.new.protected_methods.ai(:plain => true, :index => false)).to eq("[\n m3(arg1, arg2) Hello\n]")
|
||||||
else
|
else
|
||||||
Hello.new.protected_methods.ai(:plain => true, :index => false).should == "[\n m3(a, b) Hello\n]"
|
expect(Hello.new.protected_methods.ai(:plain => true, :index => false)).to eq("[\n m3(a, b) Hello\n]")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -157,8 +157,8 @@ describe "Object methods" do
|
||||||
end
|
end
|
||||||
|
|
||||||
out = Hello.new.private_methods.ai(:plain => true).split("\n").grep(/m\d/)
|
out = Hello.new.private_methods.ai(:plain => true).split("\n").grep(/m\d/)
|
||||||
out.first.should =~ /^\s+\[\s*\d+\]\s+m1\(\)\s+Hello$/
|
expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello$/)
|
||||||
out.last.should =~ /^\s+\[\s*\d+\]\s+m2\(\)\s+Hello$/
|
expect(out.last).to match(/^\s+\[\s*\d+\]\s+m2\(\)\s+Hello$/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "no index: should handle object.private_methods" do
|
it "no index: should handle object.private_methods" do
|
||||||
|
@ -168,9 +168,9 @@ describe "Object methods" do
|
||||||
end
|
end
|
||||||
out = Hello.new.private_methods.ai(:plain => true).split("\n").grep(/m\d/)
|
out = Hello.new.private_methods.ai(:plain => true).split("\n").grep(/m\d/)
|
||||||
if RUBY_VERSION < '1.9.2'
|
if RUBY_VERSION < '1.9.2'
|
||||||
out.first.should =~ /^\s+\[\s*\d+\]\s+m3\(arg1, arg2\)\s+Hello$/
|
expect(out.first).to match(/^\s+\[\s*\d+\]\s+m3\(arg1, arg2\)\s+Hello$/)
|
||||||
else
|
else
|
||||||
out.first.should =~ /^\s+\[\s*\d+\]\s+m3\(a, b\)\s+Hello$/
|
expect(out.first).to match(/^\s+\[\s*\d+\]\s+m3\(a, b\)\s+Hello$/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -184,8 +184,8 @@ describe "Object methods" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
out = Hello.singleton_methods.ai(:plain => true).split("\n").grep(/m\d/)
|
out = Hello.singleton_methods.ai(:plain => true).split("\n").grep(/m\d/)
|
||||||
out.first.should =~ /^\s+\[\s*\d+\]\s+m1\(\)\s+Hello$/
|
expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello$/)
|
||||||
out.last.should =~ /^\s+\[\s*\d+\]\s+m2\(\)\s+Hello$/
|
expect(out.last).to match(/^\s+\[\s*\d+\]\s+m2\(\)\s+Hello$/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "no index: should handle object.singleton_methods" do
|
it "no index: should handle object.singleton_methods" do
|
||||||
|
@ -194,9 +194,9 @@ describe "Object methods" do
|
||||||
end
|
end
|
||||||
out = Hello.singleton_methods.ai(:plain => true, :index => false).split("\n").grep(/m\d/)
|
out = Hello.singleton_methods.ai(:plain => true, :index => false).split("\n").grep(/m\d/)
|
||||||
if RUBY_VERSION < '1.9.2'
|
if RUBY_VERSION < '1.9.2'
|
||||||
out.first.should =~ /^\s+m3\(arg1, arg2\)\s+Hello$/
|
expect(out.first).to match(/^\s+m3\(arg1, arg2\)\s+Hello$/)
|
||||||
else
|
else
|
||||||
out.first.should =~ /^\s+m3\(a, b\)\s+Hello$/
|
expect(out.first).to match(/^\s+m3\(a, b\)\s+Hello$/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -218,8 +218,8 @@ describe "Class methods" do
|
||||||
def m2; end
|
def m2; end
|
||||||
end
|
end
|
||||||
out = Hello.instance_methods.ai(:plain => true).split("\n").grep(/m\d/)
|
out = Hello.instance_methods.ai(:plain => true).split("\n").grep(/m\d/)
|
||||||
out.first.should =~ /^\s+\[\s*\d+\]\s+m1\(\)\s+Hello\s\(unbound\)$/
|
expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello\s\(unbound\)$/)
|
||||||
out.last.should =~ /^\s+\[\s*\d+\]\s+m2\(\)\s+Hello\s\(unbound\)$/
|
expect(out.last).to match(/^\s+\[\s*\d+\]\s+m2\(\)\s+Hello\s\(unbound\)$/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "no index: should handle unbound class.instance_methods" do
|
it "no index: should handle unbound class.instance_methods" do
|
||||||
|
@ -228,9 +228,9 @@ describe "Class methods" do
|
||||||
end
|
end
|
||||||
out = Hello.instance_methods.ai(:plain => true, :index => false).split("\n").grep(/m\d/)
|
out = Hello.instance_methods.ai(:plain => true, :index => false).split("\n").grep(/m\d/)
|
||||||
if RUBY_VERSION < '1.9.2'
|
if RUBY_VERSION < '1.9.2'
|
||||||
out.first.should =~ /^\s+m3\(arg1, arg2\)\s+Hello\s\(unbound\)$/
|
expect(out.first).to match(/^\s+m3\(arg1, arg2\)\s+Hello\s\(unbound\)$/)
|
||||||
else
|
else
|
||||||
out.first.should =~ /^\s+m3\(a, b\)\s+Hello\s\(unbound\)$/
|
expect(out.first).to match(/^\s+m3\(a, b\)\s+Hello\s\(unbound\)$/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -242,8 +242,8 @@ describe "Class methods" do
|
||||||
def m2; end
|
def m2; end
|
||||||
end
|
end
|
||||||
out = Hello.public_instance_methods.ai(:plain => true).split("\n").grep(/m\d/)
|
out = Hello.public_instance_methods.ai(:plain => true).split("\n").grep(/m\d/)
|
||||||
out.first.should =~ /^\s+\[\s*\d+\]\s+m1\(\)\s+Hello\s\(unbound\)$/
|
expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello\s\(unbound\)$/)
|
||||||
out.last.should =~ /^\s+\[\s*\d+\]\s+m2\(\)\s+Hello\s\(unbound\)$/
|
expect(out.last).to match(/^\s+\[\s*\d+\]\s+m2\(\)\s+Hello\s\(unbound\)$/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "no index: should handle class.public_instance_methods" do
|
it "no index: should handle class.public_instance_methods" do
|
||||||
|
@ -252,9 +252,9 @@ describe "Class methods" do
|
||||||
end
|
end
|
||||||
out = Hello.public_instance_methods.ai(:plain => true, :index => false).split("\n").grep(/m\d/)
|
out = Hello.public_instance_methods.ai(:plain => true, :index => false).split("\n").grep(/m\d/)
|
||||||
if RUBY_VERSION < '1.9.2'
|
if RUBY_VERSION < '1.9.2'
|
||||||
out.first.should =~ /^\s+m3\(arg1, arg2\)\s+Hello\s\(unbound\)$/
|
expect(out.first).to match(/^\s+m3\(arg1, arg2\)\s+Hello\s\(unbound\)$/)
|
||||||
else
|
else
|
||||||
out.first.should =~ /^\s+m3\(a, b\)\s+Hello\s\(unbound\)$/
|
expect(out.first).to match(/^\s+m3\(a, b\)\s+Hello\s\(unbound\)$/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -267,8 +267,8 @@ describe "Class methods" do
|
||||||
def m2; end
|
def m2; end
|
||||||
end
|
end
|
||||||
out = Hello.protected_instance_methods.ai(:plain => true).split("\n").grep(/m\d/)
|
out = Hello.protected_instance_methods.ai(:plain => true).split("\n").grep(/m\d/)
|
||||||
out.first.should =~ /^\s+\[\s*\d+\]\s+m1\(\)\s+Hello\s\(unbound\)$/
|
expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello\s\(unbound\)$/)
|
||||||
out.last.should =~ /^\s+\[\s*\d+\]\s+m2\(\)\s+Hello\s\(unbound\)$/
|
expect(out.last).to match(/^\s+\[\s*\d+\]\s+m2\(\)\s+Hello\s\(unbound\)$/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "no index: should handle class.protected_instance_methods" do
|
it "no index: should handle class.protected_instance_methods" do
|
||||||
|
@ -278,9 +278,9 @@ describe "Class methods" do
|
||||||
end
|
end
|
||||||
out = Hello.protected_instance_methods.ai(:plain => true, :index => false).split("\n").grep(/m\d/)
|
out = Hello.protected_instance_methods.ai(:plain => true, :index => false).split("\n").grep(/m\d/)
|
||||||
if RUBY_VERSION < '1.9.2'
|
if RUBY_VERSION < '1.9.2'
|
||||||
out.first.should =~ /^\s+m3\(arg1, arg2\)\s+Hello\s\(unbound\)$/
|
expect(out.first).to match(/^\s+m3\(arg1, arg2\)\s+Hello\s\(unbound\)$/)
|
||||||
else
|
else
|
||||||
out.first.should =~ /^\s+m3\(a, b\)\s+Hello\s\(unbound\)$/
|
expect(out.first).to match(/^\s+m3\(a, b\)\s+Hello\s\(unbound\)$/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -293,8 +293,8 @@ describe "Class methods" do
|
||||||
def m2; end
|
def m2; end
|
||||||
end
|
end
|
||||||
out = Hello.private_instance_methods.ai(:plain => true).split("\n").grep(/m\d/)
|
out = Hello.private_instance_methods.ai(:plain => true).split("\n").grep(/m\d/)
|
||||||
out.first.should =~ /^\s+\[\s*\d+\]\s+m1\(\)\s+Hello\s\(unbound\)$/
|
expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello\s\(unbound\)$/)
|
||||||
out.last.should =~ /^\s+\[\s*\d+\]\s+m2\(\)\s+Hello\s\(unbound\)$/
|
expect(out.last).to match(/^\s+\[\s*\d+\]\s+m2\(\)\s+Hello\s\(unbound\)$/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "no index: should handle class.private_instance_methods" do
|
it "no index: should handle class.private_instance_methods" do
|
||||||
|
@ -304,9 +304,9 @@ describe "Class methods" do
|
||||||
end
|
end
|
||||||
out = Hello.private_instance_methods.ai(:plain => true, :index => false).split("\n").grep(/m\d/)
|
out = Hello.private_instance_methods.ai(:plain => true, :index => false).split("\n").grep(/m\d/)
|
||||||
if RUBY_VERSION < '1.9.2'
|
if RUBY_VERSION < '1.9.2'
|
||||||
out.first.should =~ /^\s+m3\(arg1, arg2\)\s+Hello\s\(unbound\)$/
|
expect(out.first).to match(/^\s+m3\(arg1, arg2\)\s+Hello\s\(unbound\)$/)
|
||||||
else
|
else
|
||||||
out.first.should =~ /^\s+m3\(a, b\)\s+Hello\s\(unbound\)$/
|
expect(out.first).to match(/^\s+m3\(a, b\)\s+Hello\s\(unbound\)$/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -327,7 +327,7 @@ if RUBY_VERSION >= '1.9.2'
|
||||||
def m1; end
|
def m1; end
|
||||||
end
|
end
|
||||||
out = Hello.new.methods.ai(:plain => true).split("\n").grep(/m1/)
|
out = Hello.new.methods.ai(:plain => true).split("\n").grep(/m1/)
|
||||||
out.first.should =~ /^\s+\[\s*\d+\]\s+m1\(\)\s+Hello$/
|
expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello$/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it ":req" do
|
it ":req" do
|
||||||
|
@ -335,7 +335,7 @@ if RUBY_VERSION >= '1.9.2'
|
||||||
def m1(a, b, c); end
|
def m1(a, b, c); end
|
||||||
end
|
end
|
||||||
out = Hello.new.methods.ai(:plain => true).split("\n").grep(/m1/)
|
out = Hello.new.methods.ai(:plain => true).split("\n").grep(/m1/)
|
||||||
out.first.should =~ /^\s+\[\s*\d+\]\s+m1\(a, b, c\)\s+Hello$/
|
expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(a, b, c\)\s+Hello$/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it ":opt" do
|
it ":opt" do
|
||||||
|
@ -343,7 +343,7 @@ if RUBY_VERSION >= '1.9.2'
|
||||||
def m1(a, b = 1, c = 2); end # m1(a, *b, *c)
|
def m1(a, b = 1, c = 2); end # m1(a, *b, *c)
|
||||||
end
|
end
|
||||||
out = Hello.new.methods.ai(:plain => true).split("\n").grep(/m1/)
|
out = Hello.new.methods.ai(:plain => true).split("\n").grep(/m1/)
|
||||||
out.first.should =~ /^\s+\[\s*\d+\]\s+m1\(a, \*b, \*c\)\s+Hello$/
|
expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(a, \*b, \*c\)\s+Hello$/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it ":rest" do
|
it ":rest" do
|
||||||
|
@ -351,7 +351,7 @@ if RUBY_VERSION >= '1.9.2'
|
||||||
def m1(*a); end # m1(*a)
|
def m1(*a); end # m1(*a)
|
||||||
end
|
end
|
||||||
out = Hello.new.methods.ai(:plain => true).split("\n").grep(/m1/)
|
out = Hello.new.methods.ai(:plain => true).split("\n").grep(/m1/)
|
||||||
out.first.should =~ /^\s+\[\s*\d+\]\s+m1\(\*a\)\s+Hello$/
|
expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\*a\)\s+Hello$/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it ":block" do
|
it ":block" do
|
||||||
|
@ -359,7 +359,7 @@ if RUBY_VERSION >= '1.9.2'
|
||||||
def m1(a, b = nil, &blk); end # m1(a, *b, &blk)
|
def m1(a, b = nil, &blk); end # m1(a, *b, &blk)
|
||||||
end
|
end
|
||||||
out = Hello.new.methods.ai(:plain => true).split("\n").grep(/m1/)
|
out = Hello.new.methods.ai(:plain => true).split("\n").grep(/m1/)
|
||||||
out.first.should =~ /^\s+\[\s*\d+\]\s+m1\(a, \*b, &blk\)\s+Hello$/
|
expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(a, \*b, &blk\)\s+Hello$/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -376,7 +376,7 @@ describe "Methods arrays" do
|
||||||
def self.m1; end
|
def self.m1; end
|
||||||
end
|
end
|
||||||
out = (Hello.methods - Class.methods).ai(:plain => true)
|
out = (Hello.methods - Class.methods).ai(:plain => true)
|
||||||
out.should == "[\n [0] m1() Hello\n]"
|
expect(out).to eq("[\n [0] m1() Hello\n]")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "obj1.methods & obj2.methods should be awesome printed" do
|
it "obj1.methods & obj2.methods should be awesome printed" do
|
||||||
|
@ -389,7 +389,7 @@ describe "Methods arrays" do
|
||||||
def self.m1; end
|
def self.m1; end
|
||||||
end
|
end
|
||||||
out = (Hello.methods & World.methods - Class.methods).ai(:plain => true)
|
out = (Hello.methods & World.methods - Class.methods).ai(:plain => true)
|
||||||
out.should == "[\n [0] m1() Hello\n]"
|
expect(out).to eq("[\n [0] m1() Hello\n]")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "obj1.methods.grep(pattern) should be awesome printed" do
|
it "obj1.methods.grep(pattern) should be awesome printed" do
|
||||||
|
@ -400,9 +400,9 @@ describe "Methods arrays" do
|
||||||
def self.m3; end
|
def self.m3; end
|
||||||
end
|
end
|
||||||
out = Hello.methods.grep(/^m1$/).ai(:plain => true)
|
out = Hello.methods.grep(/^m1$/).ai(:plain => true)
|
||||||
out.should == "[\n [0] m1() Hello\n]"
|
expect(out).to eq("[\n [0] m1() Hello\n]")
|
||||||
out = Hello.methods.grep(/^m\d$/).ai(:plain => true)
|
out = Hello.methods.grep(/^m\d$/).ai(:plain => true)
|
||||||
out.should == "[\n [0] m1() Hello\n [1] m2() Hello\n [2] m3() Hello\n]"
|
expect(out).to eq("[\n [0] m1() Hello\n [1] m2() Hello\n [2] m3() Hello\n]")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "obj1.methods.grep(pattern, &block) should pass the matching string within the block" do
|
it "obj1.methods.grep(pattern, &block) should pass the matching string within the block" do
|
||||||
|
@ -412,7 +412,7 @@ describe "Methods arrays" do
|
||||||
end
|
end
|
||||||
|
|
||||||
out = Hello.methods.sort.grep(/^m_(.+)$/) { $1.to_sym }
|
out = Hello.methods.sort.grep(/^m_(.+)$/) { $1.to_sym }
|
||||||
out.should == [:one, :two]
|
expect(out).to eq([:one, :two])
|
||||||
end
|
end
|
||||||
|
|
||||||
it "obj1.methods.grep(pattern, &block) should be awesome printed" do
|
it "obj1.methods.grep(pattern, &block) should be awesome printed" do
|
||||||
|
@ -425,7 +425,7 @@ describe "Methods arrays" do
|
||||||
end
|
end
|
||||||
|
|
||||||
out = Hello.methods.grep(/^m(\d)$/) { %w(none one)[$1.to_i] }.ai(:plain => true)
|
out = Hello.methods.grep(/^m(\d)$/) { %w(none one)[$1.to_i] }.ai(:plain => true)
|
||||||
out.should == "[\n [0] none() Hello\n [1] one() Hello\n]"
|
expect(out).to eq("[\n [0] none() Hello\n [1] one() Hello\n]")
|
||||||
end
|
end
|
||||||
|
|
||||||
# See https://github.com/michaeldv/awesome_print/issues/30 for details.
|
# See https://github.com/michaeldv/awesome_print/issues/30 for details.
|
||||||
|
@ -444,16 +444,16 @@ describe "Methods arrays" do
|
||||||
end
|
end
|
||||||
|
|
||||||
hello = Hello.new
|
hello = Hello.new
|
||||||
(hello.send(:his) - hello.send(:her)).sort_by { |x| x.to_s }.should == [ :him, :his ]
|
expect((hello.send(:his) - hello.send(:her)).sort_by { |x| x.to_s }).to eq([ :him, :his ])
|
||||||
end
|
end
|
||||||
|
|
||||||
it "appending garbage to methods array should not raise error" do
|
it "appending garbage to methods array should not raise error" do
|
||||||
arr = 42.methods << [ :wtf ]
|
arr = 42.methods << [ :wtf ]
|
||||||
arr.ai(:plain => true).should_not raise_error(TypeError)
|
expect(arr.ai(:plain => true)).not_to raise_error
|
||||||
if RUBY_VERSION < '1.9.2'
|
if RUBY_VERSION < '1.9.2'
|
||||||
arr.ai(:plain => true).should =~ /\s+wtf\(\?\)\s+\?/ # [ :wtf ].to_s => "wtf"
|
expect(arr.ai(:plain => true)).to match(/\s+wtf\(\?\)\s+\?/) # [ :wtf ].to_s => "wtf"
|
||||||
else
|
else
|
||||||
arr.ai(:plain => true).should =~ /\s+\[:wtf\]\(\?\)\s+\?/ # [ :wtf ].to_s => [:wtf]
|
expect(arr.ai(:plain => true)).to match(/\s+\[:wtf\]\(\?\)\s+\?/) # [ :wtf ].to_s => [:wtf]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,7 @@ describe "AwesomePrint" do
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
weird.new.ai(:plain => true).should == ''
|
expect(weird.new.ai(:plain => true)).to eq('')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "handle frozen object.inspect" do
|
it "handle frozen object.inspect" do
|
||||||
|
@ -22,14 +22,14 @@ describe "AwesomePrint" do
|
||||||
"ice".freeze
|
"ice".freeze
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
weird.new.ai(:plain => false).should == "ice"
|
expect(weird.new.ai(:plain => false)).to eq("ice")
|
||||||
end
|
end
|
||||||
|
|
||||||
# See https://github.com/michaeldv/awesome_print/issues/35
|
# See https://github.com/michaeldv/awesome_print/issues/35
|
||||||
it "handle array grep when pattern contains / chapacter" do
|
it "handle array grep when pattern contains / chapacter" do
|
||||||
hash = { "1/x" => 1, "2//x" => :"2" }
|
hash = { "1/x" => 1, "2//x" => :"2" }
|
||||||
grepped = hash.keys.sort.grep(/^(\d+)\//) { $1 }
|
grepped = hash.keys.sort.grep(/^(\d+)\//) { $1 }
|
||||||
grepped.ai(:plain => true, :multiline => false).should == '[ "1", "2" ]'
|
expect(grepped.ai(:plain => true, :multiline => false)).to eq('[ "1", "2" ]')
|
||||||
end
|
end
|
||||||
|
|
||||||
# See https://github.com/michaeldv/awesome_print/issues/85
|
# See https://github.com/michaeldv/awesome_print/issues/85
|
||||||
|
@ -37,32 +37,32 @@ describe "AwesomePrint" do
|
||||||
it "handle array grep when a method is defined in C and thus doesn't have a binding" do
|
it "handle array grep when a method is defined in C and thus doesn't have a binding" do
|
||||||
arr = (0..6).to_a
|
arr = (0..6).to_a
|
||||||
grepped = arr.grep(1..4, &:succ)
|
grepped = arr.grep(1..4, &:succ)
|
||||||
grepped.ai(:plain => true, :multiline => false).should == '[ 2, 3, 4, 5 ]'
|
expect(grepped.ai(:plain => true, :multiline => false)).to eq('[ 2, 3, 4, 5 ]')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns value passed as a parameter" do
|
it "returns value passed as a parameter" do
|
||||||
object = rand
|
object = rand
|
||||||
self.stub!(:puts)
|
allow(self).to receive(:puts)
|
||||||
(ap object).should == object
|
expect(ap object).to eq(object)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Require different file name this time (lib/ap.rb vs. lib/awesome_print).
|
# Require different file name this time (lib/ap.rb vs. lib/awesome_print).
|
||||||
it "several require 'awesome_print' should do no harm" do
|
it "several require 'awesome_print' should do no harm" do
|
||||||
require File.expand_path(File.dirname(__FILE__) + '/../lib/ap')
|
require File.expand_path(File.dirname(__FILE__) + '/../lib/ap')
|
||||||
lambda { rand.ai }.should_not raise_error
|
expect { rand.ai }.not_to raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
it "format ENV as hash" do
|
it "format ENV as hash" do
|
||||||
ENV.ai(:plain => true).should == ENV.to_hash.ai(:plain => true)
|
expect(ENV.ai(:plain => true)).to eq(ENV.to_hash.ai(:plain => true))
|
||||||
ENV.ai.should == ENV.to_hash.ai
|
expect(ENV.ai).to eq(ENV.to_hash.ai)
|
||||||
end
|
end
|
||||||
|
|
||||||
# See https://github.com/michaeldv/awesome_print/issues/134
|
# See https://github.com/michaeldv/awesome_print/issues/134
|
||||||
it "IPAddr workaround" do
|
it "IPAddr workaround" do
|
||||||
require "ipaddr"
|
require "ipaddr"
|
||||||
ipaddr = IPAddr.new("3ffe:505:2::1")
|
ipaddr = IPAddr.new("3ffe:505:2::1")
|
||||||
ipaddr.ai.should == "#<IPAddr: IPv6:3ffe:0505:0002:0000:0000:0000:0000:0001/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff>"
|
expect(ipaddr.ai).to eq("#<IPAddr: IPv6:3ffe:0505:0002:0000:0000:0000:0000:0001/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff>")
|
||||||
end
|
end
|
||||||
|
|
||||||
# See https://github.com/michaeldv/awesome_print/issues/139
|
# See https://github.com/michaeldv/awesome_print/issues/139
|
||||||
|
@ -74,7 +74,7 @@ describe "AwesomePrint" do
|
||||||
end
|
end
|
||||||
alias :eql? :==
|
alias :eql? :==
|
||||||
end
|
end
|
||||||
lambda { weird.new.ai }.should_not raise_error
|
expect { weird.new.ai }.not_to raise_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -86,17 +86,17 @@ describe "AwesomePrint" do
|
||||||
|
|
||||||
it "wraps ap output with plain <pre> tag" do
|
it "wraps ap output with plain <pre> tag" do
|
||||||
markup = rand
|
markup = rand
|
||||||
markup.ai(:html => true, :plain => true).should == "<pre>#{markup}</pre>"
|
expect(markup.ai(:html => true, :plain => true)).to eq("<pre>#{markup}</pre>")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "wraps ap output with <pre> tag with colorized <kbd>" do
|
it "wraps ap output with <pre> tag with colorized <kbd>" do
|
||||||
markup = rand
|
markup = rand
|
||||||
markup.ai(:html => true).should == %Q|<pre><kbd style="color:blue">#{markup}</kbd></pre>|
|
expect(markup.ai(:html => true)).to eq(%Q|<pre><kbd style="color:blue">#{markup}</kbd></pre>|)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "wraps multiline ap output with <pre> tag with colorized <kbd>" do
|
it "wraps multiline ap output with <pre> tag with colorized <kbd>" do
|
||||||
markup = [ 1, :two, "three" ]
|
markup = [ 1, :two, "three" ]
|
||||||
markup.ai(:html => true).should == <<-EOS.strip
|
expect(markup.ai(:html => true)).to eq <<-EOS.strip
|
||||||
<pre>[
|
<pre>[
|
||||||
<kbd style="color:white">[0] </kbd><kbd style="color:blue">1</kbd>,
|
<kbd style="color:white">[0] </kbd><kbd style="color:blue">1</kbd>,
|
||||||
<kbd style="color:white">[1] </kbd><kbd style="color:darkcyan">:two</kbd>,
|
<kbd style="color:white">[1] </kbd><kbd style="color:darkcyan">:two</kbd>,
|
||||||
|
@ -107,7 +107,7 @@ EOS
|
||||||
|
|
||||||
it "wraps hash ap output with only an outer <pre> tag" do
|
it "wraps hash ap output with only an outer <pre> tag" do
|
||||||
markup = [ { "hello" => "world" } ]
|
markup = [ { "hello" => "world" } ]
|
||||||
markup.ai(:html => true).should == <<-EOS.strip
|
expect(markup.ai(:html => true)).to eq <<-EOS.strip
|
||||||
<pre>[
|
<pre>[
|
||||||
<kbd style="color:white">[0] </kbd>{
|
<kbd style="color:white">[0] </kbd>{
|
||||||
"hello"<kbd style="color:slategray"> => </kbd><kbd style="color:brown">"world"</kbd>
|
"hello"<kbd style="color:slategray"> => </kbd><kbd style="color:brown">"world"</kbd>
|
||||||
|
@ -118,12 +118,12 @@ EOS
|
||||||
|
|
||||||
it "encodes HTML entities (plain)" do
|
it "encodes HTML entities (plain)" do
|
||||||
markup = ' &<hello>'
|
markup = ' &<hello>'
|
||||||
markup.ai(:html => true, :plain => true).should == '<pre>" &<hello>"</pre>'
|
expect(markup.ai(:html => true, :plain => true)).to eq('<pre>" &<hello>"</pre>')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "encodes HTML entities (color)" do
|
it "encodes HTML entities (color)" do
|
||||||
markup = ' &<hello>'
|
markup = ' &<hello>'
|
||||||
markup.ai(:html => true).should == '<pre><kbd style="color:brown">" &<hello>"</kbd></pre>'
|
expect(markup.ai(:html => true)).to eq('<pre><kbd style="color:brown">" &<hello>"</kbd></pre>')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ EOS
|
||||||
AwesomePrint.defaults = { :indent => -2, :sort_keys => true }
|
AwesomePrint.defaults = { :indent => -2, :sort_keys => true }
|
||||||
hash = { [0, 0, 255] => :yellow, :red => "rgb(255, 0, 0)", "magenta" => "rgb(255, 0, 255)" }
|
hash = { [0, 0, 255] => :yellow, :red => "rgb(255, 0, 0)", "magenta" => "rgb(255, 0, 255)" }
|
||||||
out = hash.ai(:plain => true)
|
out = hash.ai(:plain => true)
|
||||||
out.should == <<-EOS.strip
|
expect(out).to eq <<-EOS.strip
|
||||||
{
|
{
|
||||||
[ 0, 0, 255 ] => :yellow,
|
[ 0, 0, 255 ] => :yellow,
|
||||||
"magenta" => "rgb(255, 0, 255)",
|
"magenta" => "rgb(255, 0, 255)",
|
||||||
|
@ -178,25 +178,25 @@ EOS
|
||||||
it "shoud not raise ArgumentError when formatting HTML" do
|
it "shoud not raise ArgumentError when formatting HTML" do
|
||||||
out = "hello".ai(:color => { :string => :red }, :html => true)
|
out = "hello".ai(:color => { :string => :red }, :html => true)
|
||||||
if RUBY_VERSION >= "1.9"
|
if RUBY_VERSION >= "1.9"
|
||||||
out.should == %Q|<pre>[red]<kbd style="color:red">"hello"</kbd>[/red]</pre>|
|
expect(out).to eq(%Q|<pre>[red]<kbd style="color:red">"hello"</kbd>[/red]</pre>|)
|
||||||
else
|
else
|
||||||
out.should == %Q|<pre>[red]"hello"[/red]</pre>|
|
expect(out).to eq(%Q|<pre>[red]"hello"[/red]</pre>|)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "shoud not raise ArgumentError when formatting HTML (shade color)" do
|
it "shoud not raise ArgumentError when formatting HTML (shade color)" do
|
||||||
out = "hello".ai(:color => { :string => :redish }, :html => true)
|
out = "hello".ai(:color => { :string => :redish }, :html => true)
|
||||||
out.should == %Q|<pre><kbd style="color:darkred">"hello"</kbd></pre>|
|
expect(out).to eq(%Q|<pre><kbd style="color:darkred">"hello"</kbd></pre>|)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "shoud not raise ArgumentError when formatting non-HTML" do
|
it "shoud not raise ArgumentError when formatting non-HTML" do
|
||||||
out = "hello".ai(:color => { :string => :red }, :html => false)
|
out = "hello".ai(:color => { :string => :red }, :html => false)
|
||||||
out.should == %Q|[red]"hello"[/red]|
|
expect(out).to eq(%Q|[red]"hello"[/red]|)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "shoud not raise ArgumentError when formatting non-HTML (shade color)" do
|
it "shoud not raise ArgumentError when formatting non-HTML (shade color)" do
|
||||||
out = "hello".ai(:color => { :string => :redish }, :html => false)
|
out = "hello".ai(:color => { :string => :redish }, :html => false)
|
||||||
out.should == %Q|\e[0;31m"hello"\e[0m|
|
expect(out).to eq(%Q|\e[0;31m"hello"\e[0m|)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -204,23 +204,23 @@ EOS
|
||||||
describe "Console" do
|
describe "Console" do
|
||||||
it "should detect IRB" do
|
it "should detect IRB" do
|
||||||
class IRB; end
|
class IRB; end
|
||||||
AwesomePrint.console?.should == true
|
expect(AwesomePrint.console?).to eq(true)
|
||||||
AwesomePrint.rails_console?.should == false
|
expect(AwesomePrint.rails_console?).to eq(false)
|
||||||
Object.instance_eval{ remove_const :IRB }
|
Object.instance_eval{ remove_const :IRB }
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should detect Pry" do
|
it "should detect Pry" do
|
||||||
class Pry; end
|
class Pry; end
|
||||||
AwesomePrint.console?.should == true
|
expect(AwesomePrint.console?).to eq(true)
|
||||||
AwesomePrint.rails_console?.should == false
|
expect(AwesomePrint.rails_console?).to eq(false)
|
||||||
Object.instance_eval{ remove_const :Pry }
|
Object.instance_eval{ remove_const :Pry }
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should detect Rails::Console" do
|
it "should detect Rails::Console" do
|
||||||
class IRB; end
|
class IRB; end
|
||||||
class Rails; class Console; end; end
|
class Rails; class Console; end; end
|
||||||
AwesomePrint.console?.should == true
|
expect(AwesomePrint.console?).to eq(true)
|
||||||
AwesomePrint.rails_console?.should == true
|
expect(AwesomePrint.rails_console?).to eq(true)
|
||||||
Object.instance_eval{ remove_const :IRB }
|
Object.instance_eval{ remove_const :IRB }
|
||||||
Object.instance_eval{ remove_const :Rails }
|
Object.instance_eval{ remove_const :Rails }
|
||||||
end
|
end
|
||||||
|
@ -228,20 +228,20 @@ EOS
|
||||||
it "should detect ENV['RAILS_ENV']" do
|
it "should detect ENV['RAILS_ENV']" do
|
||||||
class Pry; end
|
class Pry; end
|
||||||
ENV["RAILS_ENV"] = "development"
|
ENV["RAILS_ENV"] = "development"
|
||||||
AwesomePrint.console?.should == true
|
expect(AwesomePrint.console?).to eq(true)
|
||||||
AwesomePrint.rails_console?.should == true
|
expect(AwesomePrint.rails_console?).to eq(true)
|
||||||
Object.instance_eval{ remove_const :Pry }
|
Object.instance_eval{ remove_const :Pry }
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should return the actual object when *not* running under console" do
|
it "should return the actual object when *not* running under console" do
|
||||||
capture! { ap([ 1, 2, 3 ]) }.should == [ 1, 2, 3 ]
|
expect(capture! { ap([ 1, 2, 3 ]) }).to eq([ 1, 2, 3 ])
|
||||||
capture! { ap({ :a => 1 }) }.should == { :a => 1 }
|
expect(capture! { ap({ :a => 1 }) }).to eq({ :a => 1 })
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should return nil when running under console" do
|
it "should return nil when running under console" do
|
||||||
class IRB; end
|
class IRB; end
|
||||||
capture! { ap([ 1, 2, 3 ]) }.should == nil
|
expect(capture! { ap([ 1, 2, 3 ]) }).to eq(nil)
|
||||||
capture! { ap({ :a => 1 }) }.should == nil
|
expect(capture! { ap({ :a => 1 }) }).to eq(nil)
|
||||||
Object.instance_eval{ remove_const :IRB }
|
Object.instance_eval{ remove_const :IRB }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,8 +30,8 @@ describe "Objects" do
|
||||||
attr_writer :ca = 2
|
attr_writer :ca = 2
|
||||||
>
|
>
|
||||||
EOS
|
EOS
|
||||||
out.gsub(/0x([a-f\d]+)/, "0x01234567").should == str
|
expect(out.gsub(/0x([a-f\d]+)/, "0x01234567")).to eq(str)
|
||||||
hello.ai(:plain => true, :raw => false).should == hello.inspect
|
expect(hello.ai(:plain => true, :raw => false)).to eq(hello.inspect)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "instance variables" do
|
it "instance variables" do
|
||||||
|
@ -50,8 +50,8 @@ EOS
|
||||||
@dabra = 3
|
@dabra = 3
|
||||||
>
|
>
|
||||||
EOS
|
EOS
|
||||||
out.gsub(/0x([a-f\d]+)/, "0x01234567").should == str
|
expect(out.gsub(/0x([a-f\d]+)/, "0x01234567")).to eq(str)
|
||||||
hello.ai(:plain => true, :raw => false).should == hello.inspect
|
expect(hello.ai(:plain => true, :raw => false)).to eq(hello.inspect)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "attributes and instance variables" do
|
it "attributes and instance variables" do
|
||||||
|
@ -78,8 +78,8 @@ EOS
|
||||||
attr_writer :ca = 2
|
attr_writer :ca = 2
|
||||||
>
|
>
|
||||||
EOS
|
EOS
|
||||||
out.gsub(/0x([a-f\d]+)/, "0x01234567").should == str
|
expect(out.gsub(/0x([a-f\d]+)/, "0x01234567")).to eq(str)
|
||||||
hello.ai(:plain => true, :raw => false).should == hello.inspect
|
expect(hello.ai(:plain => true, :raw => false)).to eq(hello.inspect)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,7 +20,7 @@ require 'awesome_print'
|
||||||
|
|
||||||
def stub_dotfile!
|
def stub_dotfile!
|
||||||
dotfile = File.join(ENV["HOME"], ".aprc")
|
dotfile = File.join(ENV["HOME"], ".aprc")
|
||||||
File.should_receive(:readable?).at_least(:once).with(dotfile).and_return(false)
|
expect(File).to receive(:readable?).at_least(:once).with(dotfile).and_return(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
def capture!
|
def capture!
|
||||||
|
|
Loading…
Reference in a new issue