awesome_print 1.2.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: aabb3e481a4a95d63ef09c71a7536fe4af4ad8da
4
+ data.tar.gz: 3c8b4bba0f9e8ee7dd138f1f1ad9035b87405629
5
+ SHA512:
6
+ metadata.gz: 1e2c1ddea1248d991a213d6cf36d9f88eedb8c8c0b5b293fa3bc5ef4870bd8a9b52b9b45deef4fa848008e2abb77dccf13d1af9eaa0f5ff669919e03a549b0e9
7
+ data.tar.gz: bea6f63b5c6f0ab9093a8273012f7069791e0486e06d04d2ae399903663664f53ffc50599f46bce190dbeb92cea0864ab2fb58d121ea3cf3c193c88ff2c1119c
data/.gitignore CHANGED
@@ -13,12 +13,18 @@ tmtags
13
13
  ## VIM
14
14
  *.swp
15
15
 
16
+ ## RUBYMINE
17
+ .idea
18
+
16
19
  ## PROJECT::GENERAL
17
20
  coverage
18
21
  rdoc
19
22
  pkg
20
- Gemfile.lock
23
+ .ruby-version
21
24
 
22
- ## PROJECT::SPECIFIC
25
+ ## PROJECT::RVM
23
26
  .rvmrc
24
- .idea
27
+
28
+ # PROJECT::RBENV
29
+ .ruby-gemset
30
+ .awesome-print/
data/CHANGELOG CHANGED
@@ -1,3 +1,15 @@
1
+ 1.6.0
2
+ semi-major release since it's been a while, and there are several
3
+ improvements.
4
+ - Improves support for new mongoid/moped (Velkitor, Francois Bernier et al)
5
+ - Converts specs to rspec 3+ (Adam Jonas, James Cox)
6
+ - Fixes incompatibility with IPAddr (James Cox, Michael Dvorkin)
7
+ - Fixes incompatibility with the money gem (Michael Dvorkin)
8
+ - Fixes AR::Relation presentation (Sergey Ponomarov)
9
+ - Lazy-loads ActionView (Akira Matsuda)
10
+ - Fixes inspection of abstract classes (Jonathan Priddle)
11
+ - Gets most specs passing, and fixes suite (Eoin Kelly)
12
+
1
13
  1.2.0 <-- NOTE: This is the *last* release supporting Ruby < v1.9.3 and Rails < v3.
2
14
  - Added Sequel ORM plugin (Jonathan Davies)
3
15
  - Added Ripple plugin (Ruby modeling layer for Riak, Scott Hyndman)
@@ -93,4 +105,4 @@
93
105
 
94
106
  0.1.0
95
107
  - Initial Release.
96
-
108
+
data/Gemfile CHANGED
@@ -1,3 +1,41 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
+ group :development do
5
+
6
+ # ActionView extension
7
+ # ####################
8
+ gem 'actionview', '>= 4.2.0'
9
+
10
+ # ActiveSupport extension
11
+ # #######################
12
+ gem 'activesupport', '>= 4.2.0'
13
+
14
+ # ActiveRecord extension
15
+ # ######################
16
+ # * To simplify creating test models we use an in-memory SQLite DB
17
+ gem 'activerecord', '>= 4.2.0'
18
+ gem 'sqlite3'
19
+
20
+ # MongoMapper extension
21
+ # #####################
22
+ # * cannot be enabled at the same time as mongoid
23
+ # gem 'mongo_mapper', '~> 0.13.0'
24
+ # gem 'bson_ext'
25
+
26
+ # Nokogiri extension
27
+ # ##################
28
+ gem 'nokogiri', '>= 1.6.5'
29
+
30
+ # Ripple extension
31
+ # ################
32
+ #
33
+ # * Ripple is abandoned http://basho.com/tag/ripple-client-apis/
34
+ # * Ripple is not currently compatible with Rails 4
35
+ # gem 'ripple', '~> 0.9.5'
36
+
37
+ # Mongoid extension
38
+ # #################
39
+ # * cannot be enabled at the same time as mongo_mapper
40
+ gem 'mongoid', '>= 4.0.0'
41
+ end
@@ -0,0 +1,91 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ awesome_print (1.2.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actionview (4.2.0)
10
+ activesupport (= 4.2.0)
11
+ builder (~> 3.1)
12
+ erubis (~> 2.7.0)
13
+ rails-dom-testing (~> 1.0, >= 1.0.5)
14
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
15
+ activemodel (4.2.0)
16
+ activesupport (= 4.2.0)
17
+ builder (~> 3.1)
18
+ activerecord (4.2.0)
19
+ activemodel (= 4.2.0)
20
+ activesupport (= 4.2.0)
21
+ arel (~> 6.0)
22
+ activesupport (4.2.0)
23
+ i18n (~> 0.7)
24
+ json (~> 1.7, >= 1.7.7)
25
+ minitest (~> 5.1)
26
+ thread_safe (~> 0.3, >= 0.3.4)
27
+ tzinfo (~> 1.1)
28
+ arel (6.0.0)
29
+ bson (2.3.0)
30
+ builder (3.2.2)
31
+ connection_pool (2.1.0)
32
+ diff-lcs (1.2.5)
33
+ erubis (2.7.0)
34
+ fakefs (0.5.3)
35
+ i18n (0.7.0)
36
+ json (1.8.1)
37
+ loofah (2.0.1)
38
+ nokogiri (>= 1.5.9)
39
+ mini_portile (0.6.1)
40
+ minitest (5.5.0)
41
+ mongoid (4.0.0)
42
+ activemodel (~> 4.0)
43
+ moped (~> 2.0.0)
44
+ origin (~> 2.1)
45
+ tzinfo (>= 0.3.37)
46
+ moped (2.0.2)
47
+ bson (~> 2.2)
48
+ connection_pool (~> 2.0)
49
+ optionable (~> 0.2.0)
50
+ nokogiri (1.6.5)
51
+ mini_portile (~> 0.6.0)
52
+ optionable (0.2.0)
53
+ origin (2.1.1)
54
+ rails-deprecated_sanitizer (1.0.3)
55
+ activesupport (>= 4.2.0.alpha)
56
+ rails-dom-testing (1.0.5)
57
+ activesupport (>= 4.2.0.beta, < 5.0)
58
+ nokogiri (~> 1.6.0)
59
+ rails-deprecated_sanitizer (>= 1.0.1)
60
+ rails-html-sanitizer (1.0.1)
61
+ loofah (~> 2.0)
62
+ rspec (3.0.0)
63
+ rspec-core (~> 3.0.0)
64
+ rspec-expectations (~> 3.0.0)
65
+ rspec-mocks (~> 3.0.0)
66
+ rspec-core (3.0.4)
67
+ rspec-support (~> 3.0.0)
68
+ rspec-expectations (3.0.4)
69
+ diff-lcs (>= 1.2.0, < 2.0)
70
+ rspec-support (~> 3.0.0)
71
+ rspec-mocks (3.0.4)
72
+ rspec-support (~> 3.0.0)
73
+ rspec-support (3.0.4)
74
+ sqlite3 (1.3.10)
75
+ thread_safe (0.3.4)
76
+ tzinfo (1.2.2)
77
+ thread_safe (~> 0.1)
78
+
79
+ PLATFORMS
80
+ ruby
81
+
82
+ DEPENDENCIES
83
+ actionview (>= 4.2.0)
84
+ activerecord (>= 4.2.0)
85
+ activesupport (>= 4.2.0)
86
+ awesome_print!
87
+ fakefs (>= 0.2.1)
88
+ mongoid (>= 4.0.0)
89
+ nokogiri (>= 1.6.5)
90
+ rspec (>= 3.0.0)
91
+ sqlite3
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  Copyright (c) 2010-2013 Michael Dvorkin
2
2
  http://www.dvorkin.net
3
- %w(mike dvorkin.net) * "@" || %w(mike fatfreecrm.com) * "@"
3
+ %w(mike dvorkin.net) * "@" || "twitter.com/mid"
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
1
  ## Awesome Print ##
2
+
3
+ [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/michaeldv/awesome_print?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
+
2
5
  Awesome Print is a Ruby library that pretty prints Ruby objects in full color
3
6
  exposing their internal structure with proper indentation. Rails ActiveRecord
4
7
  objects and usage within Rails templates are supported via included mixins.
data/lib/ap.rb CHANGED
File without changes
@@ -25,11 +25,16 @@ unless defined?(AwesomePrint::Inspector)
25
25
  #
26
26
  # Load remaining extensions.
27
27
  #
28
- require File.dirname(__FILE__) + "/awesome_print/ext/action_view" if defined?(ActionView::Base)
28
+ if defined?(ActiveSupport)
29
+ ActiveSupport.on_load(:action_view) do
30
+ require File.dirname(__FILE__) + "/awesome_print/ext/action_view"
31
+ end
32
+ end
29
33
  require File.dirname(__FILE__) + "/awesome_print/ext/mongo_mapper" if defined?(MongoMapper)
30
34
  require File.dirname(__FILE__) + "/awesome_print/ext/mongoid" if defined?(Mongoid)
31
35
  require File.dirname(__FILE__) + "/awesome_print/ext/nokogiri" if defined?(Nokogiri)
32
36
  require File.dirname(__FILE__) + "/awesome_print/ext/no_brainer" if defined?(NoBrainer)
33
37
  require File.dirname(__FILE__) + "/awesome_print/ext/ripple" if defined?(Ripple)
34
38
  require File.dirname(__FILE__) + "/awesome_print/ext/sequel" if defined?(Sequel)
39
+ require File.dirname(__FILE__) + "/awesome_print/ext/ostruct" if defined?(OpenStruct)
35
40
  end
@@ -21,7 +21,7 @@ module AwesomePrint
21
21
  cast = :active_record_instance
22
22
  elsif object.is_a?(Class) && object.ancestors.include?(::ActiveRecord::Base)
23
23
  cast = :active_record_class
24
- elsif type == :activerecord_relation
24
+ elsif type == :activerecord_relation || object.class.ancestors.include?(::ActiveRecord::Relation)
25
25
  cast = :array
26
26
  end
27
27
  cast
@@ -56,6 +56,7 @@ module AwesomePrint
56
56
  #------------------------------------------------------------------------------
57
57
  def awesome_active_record_class(object)
58
58
  return object.inspect if !defined?(::ActiveSupport::OrderedHash) || !object.respond_to?(:columns) || object.to_s == "ActiveRecord::Base"
59
+ return awesome_class(object) if object.respond_to?(:abstract_class?) && object.abstract_class?
59
60
 
60
61
  data = object.columns.inject(::ActiveSupport::OrderedHash.new) do |hash, c|
61
62
  hash[c.name.to_sym] = c.type
@@ -20,7 +20,7 @@ module AwesomePrint
20
20
  cast = :mongoid_class
21
21
  elsif object.class.ancestors.include?(::Mongoid::Document)
22
22
  cast = :mongoid_document
23
- elsif (defined?(::BSON) && object.is_a?(::BSON::ObjectId)) || (defined?(::Moped) && object.is_a?(::Moped::BSON::ObjectId))
23
+ elsif (defined?(::BSON) && object.is_a?(::BSON::ObjectId)) || (defined?(::Moped::BSON) && object.is_a?(::Moped::BSON::ObjectId))
24
24
  cast = :mongoid_bson_id
25
25
  end
26
26
  end
@@ -0,0 +1,27 @@
1
+ # Copyright (c) 2010-2013 Michael Dvorkin
2
+ #
3
+ # Awesome Print is freely distributable under the terms of MIT license.
4
+ # See LICENSE file or http://www.opensource.org/licenses/mit-license.php
5
+ #------------------------------------------------------------------------------
6
+ module AwesomePrint
7
+ module OpenStruct
8
+ def self.included(base)
9
+ base.send :alias_method, :cast_without_ostruct, :cast
10
+ base.send :alias_method, :cast, :cast_with_ostruct
11
+ end
12
+
13
+ def cast_with_ostruct(object, type)
14
+ cast = cast_without_ostruct(object, type)
15
+ if (defined?(::OpenStruct)) && (object.is_a?(::OpenStruct))
16
+ cast = :open_struct_instance
17
+ end
18
+ cast
19
+ end
20
+
21
+ def awesome_open_struct_instance(object)
22
+ "#{object.class} #{awesome_hash(object.marshal_dump)}"
23
+ end
24
+ end
25
+ end
26
+
27
+ AwesomePrint::Formatter.send(:include, AwesomePrint::OpenStruct)
@@ -63,7 +63,7 @@ module AwesomePrint
63
63
  def awesome_self(object, type)
64
64
  if @options[:raw] && object.instance_variables.any?
65
65
  awesome_object(object)
66
- elsif object == ENV
66
+ elsif object.respond_to?(:to_hash)
67
67
  awesome_hash(object.to_hash)
68
68
  else
69
69
  colorize(object.inspect.to_s, type)
File without changes
@@ -5,6 +5,6 @@
5
5
  #------------------------------------------------------------------------------
6
6
  module AwesomePrint
7
7
  def self.version
8
- "1.2.0"
8
+ "1.6.0"
9
9
  end
10
10
  end
@@ -0,0 +1,42 @@
1
+ require 'active_record'
2
+
3
+ # Required to use the column support
4
+ module Rails
5
+ def self.env
6
+ {}
7
+ end
8
+ end
9
+
10
+ # Establish connection to in-memory SQLite DB
11
+ ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
12
+
13
+ # Create the users table
14
+ ActiveRecord::Migration.verbose = false
15
+ ActiveRecord::Migration.create_table :users do |t|
16
+ t.string :name
17
+ t.integer :rank
18
+ t.boolean :admin
19
+ t.datetime :created_at
20
+ end
21
+
22
+ # Create models
23
+ class User < ActiveRecord::Base; end
24
+ class SubUser < User; end
25
+
26
+
27
+ # Helper methods
28
+ # ##############
29
+
30
+ def activerecord_version
31
+ # ActiveRecord 4+
32
+ return ActiveRecord.version.to_s if ActiveRecord.method_defined? :version
33
+
34
+ # everything else
35
+ ActiveRecord::VERSION::STRING
36
+ end
37
+
38
+ # we only work with ActiveRecord 2+
39
+ def is_usable_activerecord?
40
+ defined?(ActiveRecord::VERSION::MAJOR) && ActiveRecord::VERSION::MAJOR >= 2
41
+ end
42
+
@@ -30,14 +30,14 @@ describe "AwesomePrint" do
30
30
 
31
31
  it "colorizes tty processes by default" do
32
32
  stub_tty!
33
- @arr.ai(:multiline => false).should == COLORIZED
33
+ expect(@arr.ai(:multiline => false)).to eq(COLORIZED)
34
34
  end
35
35
 
36
36
  it "colorizes processes with ENV['ANSICON'] by default" do
37
37
  begin
38
38
  stub_tty!
39
39
  term, ENV['ANSICON'] = ENV['ANSICON'], "1"
40
- @arr.ai(:multiline => false).should == COLORIZED
40
+ expect(@arr.ai(:multiline => false)).to eq(COLORIZED)
41
41
  ensure
42
42
  ENV['ANSICON'] = term
43
43
  end
@@ -47,7 +47,7 @@ describe "AwesomePrint" do
47
47
  begin
48
48
  stub_tty!
49
49
  term, ENV['TERM'] = ENV['TERM'], "dumb"
50
- @arr.ai(:multiline => false).should == PLAIN
50
+ expect(@arr.ai(:multiline => false)).to eq(PLAIN)
51
51
  ensure
52
52
  ENV['TERM'] = term
53
53
  end
@@ -56,7 +56,7 @@ describe "AwesomePrint" do
56
56
  it "does not colorize subprocesses by default" do
57
57
  begin
58
58
  stub_tty! false
59
- @arr.ai(:multiline => false).should == PLAIN
59
+ expect(@arr.ai(:multiline => false)).to eq(PLAIN)
60
60
  ensure
61
61
  stub_tty!
62
62
  end
@@ -70,14 +70,14 @@ describe "AwesomePrint" do
70
70
 
71
71
  it "still colorizes tty processes" do
72
72
  stub_tty!
73
- @arr.ai(:multiline => false).should == COLORIZED
73
+ expect(@arr.ai(:multiline => false)).to eq(COLORIZED)
74
74
  end
75
75
 
76
76
  it "colorizes processes with ENV['ANSICON'] set to 0" do
77
77
  begin
78
78
  stub_tty!
79
79
  term, ENV['ANSICON'] = ENV['ANSICON'], "1"
80
- @arr.ai(:multiline => false).should == COLORIZED
80
+ expect(@arr.ai(:multiline => false)).to eq(COLORIZED)
81
81
  ensure
82
82
  ENV['ANSICON'] = term
83
83
  end
@@ -87,7 +87,7 @@ describe "AwesomePrint" do
87
87
  begin
88
88
  stub_tty!
89
89
  term, ENV['TERM'] = ENV['TERM'], "dumb"
90
- @arr.ai(:multiline => false).should == COLORIZED
90
+ expect(@arr.ai(:multiline => false)).to eq(COLORIZED)
91
91
  ensure
92
92
  ENV['TERM'] = term
93
93
  end
@@ -96,7 +96,7 @@ describe "AwesomePrint" do
96
96
  it "colorizes subprocess" do
97
97
  begin
98
98
  stub_tty! false
99
- @arr.ai(:multiline => false).should == COLORIZED
99
+ expect(@arr.ai(:multiline => false)).to eq(COLORIZED)
100
100
  ensure
101
101
  stub_tty!
102
102
  end
@@ -14,11 +14,11 @@ describe "AwesomePrint" do
14
14
  end
15
15
 
16
16
  it "empty array" do
17
- [].ai.should == "[]"
17
+ expect([].ai).to eq("[]")
18
18
  end
19
19
 
20
20
  it "plain multiline" do
21
- @arr.ai(:plain => true).should == <<-EOS.strip
21
+ expect(@arr.ai(:plain => true)).to eq <<-EOS.strip
22
22
  [
23
23
  [0] 1,
24
24
  [1] :two,
@@ -35,7 +35,7 @@ EOS
35
35
  end
36
36
 
37
37
  it "plain multiline without index" do
38
- @arr.ai(:plain => true, :index => false).should == <<-EOS.strip
38
+ expect(@arr.ai(:plain => true, :index => false)).to eq <<-EOS.strip
39
39
  [
40
40
  1,
41
41
  :two,
@@ -52,7 +52,7 @@ EOS
52
52
  end
53
53
 
54
54
  it "plain multiline indented" do
55
- @arr.ai(:plain => true, :indent => 2).should == <<-EOS.strip
55
+ expect(@arr.ai(:plain => true, :indent => 2)).to eq <<-EOS.strip
56
56
  [
57
57
  [0] 1,
58
58
  [1] :two,
@@ -69,7 +69,7 @@ EOS
69
69
  end
70
70
 
71
71
  it "plain multiline indented without index" do
72
- @arr.ai(:plain => true, :indent => 2, :index => false).should == <<-EOS.strip
72
+ expect(@arr.ai(:plain => true, :indent => 2, :index => false)).to eq <<-EOS.strip
73
73
  [
74
74
  1,
75
75
  :two,
@@ -86,11 +86,11 @@ EOS
86
86
  end
87
87
 
88
88
  it "plain single line" do
89
- @arr.ai(:plain => true, :multiline => false).should == '[ 1, :two, "three", [ nil, [ true, false ] ] ]'
89
+ expect(@arr.ai(:plain => true, :multiline => false)).to eq('[ 1, :two, "three", [ nil, [ true, false ] ] ]')
90
90
  end
91
91
 
92
92
  it "colored multiline (default)" do
93
- @arr.ai.should == <<-EOS.strip
93
+ expect(@arr.ai).to eq <<-EOS.strip
94
94
  [
95
95
  \e[1;37m[0] \e[0m\e[1;34m1\e[0m,
96
96
  \e[1;37m[1] \e[0m\e[0;36m:two\e[0m,
@@ -107,7 +107,7 @@ EOS
107
107
  end
108
108
 
109
109
  it "colored multiline indented" do
110
- @arr.ai(:indent => 8).should == <<-EOS.strip
110
+ expect(@arr.ai(:indent => 8)).to eq <<-EOS.strip
111
111
  [
112
112
  \e[1;37m[0] \e[0m\e[1;34m1\e[0m,
113
113
  \e[1;37m[1] \e[0m\e[0;36m:two\e[0m,
@@ -124,7 +124,7 @@ EOS
124
124
  end
125
125
 
126
126
  it "colored single line" do
127
- @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 ] ] ]"
127
+ 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 ] ] ]")
128
128
  end
129
129
  end
130
130
 
@@ -136,7 +136,7 @@ EOS
136
136
  end
137
137
 
138
138
  it "plain multiline" do
139
- @arr.ai(:plain => true).should == <<-EOS.strip
139
+ expect(@arr.ai(:plain => true)).to eq <<-EOS.strip
140
140
  [
141
141
  [0] 1,
142
142
  [1] 2,
@@ -146,7 +146,7 @@ EOS
146
146
  end
147
147
 
148
148
  it "plain multiline without index" do
149
- @arr.ai(:plain => true, :index => false).should == <<-EOS.strip
149
+ expect(@arr.ai(:plain => true, :index => false)).to eq <<-EOS.strip
150
150
  [
151
151
  1,
152
152
  2,
@@ -156,7 +156,7 @@ EOS
156
156
  end
157
157
 
158
158
  it "plain single line" do
159
- @arr.ai(:plain => true, :multiline => false).should == "[ 1, 2, [...] ]"
159
+ expect(@arr.ai(:plain => true, :multiline => false)).to eq("[ 1, 2, [...] ]")
160
160
  end
161
161
  end
162
162
 
@@ -167,7 +167,7 @@ EOS
167
167
  end
168
168
 
169
169
  it "plain limited output large" do
170
- @arr.ai(:plain => true, :limit => true).should == <<-EOS.strip
170
+ expect(@arr.ai(:plain => true, :limit => true)).to eq <<-EOS.strip
171
171
  [
172
172
  [ 0] 1,
173
173
  [ 1] 2,
@@ -182,7 +182,7 @@ EOS
182
182
 
183
183
  it "plain limited output small" do
184
184
  @arr = @arr[0..3]
185
- @arr.ai(:plain => true, :limit => true).should == <<-EOS.strip
185
+ expect(@arr.ai(:plain => true, :limit => true)).to eq <<-EOS.strip
186
186
  [
187
187
  [0] 1,
188
188
  [1] 2,
@@ -193,7 +193,7 @@ EOS
193
193
  end
194
194
 
195
195
  it "plain limited output with 10 lines" do
196
- @arr.ai(:plain => true, :limit => 10).should == <<-EOS.strip
196
+ expect(@arr.ai(:plain => true, :limit => 10)).to eq <<-EOS.strip
197
197
  [
198
198
  [ 0] 1,
199
199
  [ 1] 2,
@@ -210,7 +210,7 @@ EOS
210
210
  end
211
211
 
212
212
  it "plain limited output with 11 lines" do
213
- @arr.ai(:plain => true, :limit => 11).should == <<-EOS.strip
213
+ expect(@arr.ai(:plain => true, :limit => 11)).to eq <<-EOS.strip
214
214
  [
215
215
  [ 0] 1,
216
216
  [ 1] 2,
@@ -235,7 +235,7 @@ EOS
235
235
  end
236
236
 
237
237
  it "plain limited output" do
238
- @hash.ai(:sort_keys => true, :plain => true, :limit => true).should == <<-EOS.strip
238
+ expect(@hash.ai(:sort_keys => true, :plain => true, :limit => true)).to eq <<-EOS.strip
239
239
  {
240
240
  "a" => :a,
241
241
  "b" => :b,
@@ -254,13 +254,13 @@ EOS
254
254
  before do
255
255
  @hash = { 1 => { :sym => { "str" => { [1, 2, 3] => { { :k => :v } => Hash } } } } }
256
256
  end
257
-
257
+
258
258
  it "empty hash" do
259
- {}.ai.should == "{}"
259
+ expect({}.ai).to eq("{}")
260
260
  end
261
-
261
+
262
262
  it "plain multiline" do
263
- @hash.ai(:plain => true).should == <<-EOS.strip
263
+ expect(@hash.ai(:plain => true)).to eq <<-EOS.strip
264
264
  {
265
265
  1 => {
266
266
  :sym => {
@@ -276,7 +276,7 @@ EOS
276
276
  end
277
277
 
278
278
  it "plain multiline indented" do
279
- @hash.ai(:plain => true, :indent => 1).should == <<-EOS.strip
279
+ expect(@hash.ai(:plain => true, :indent => 1)).to eq <<-EOS.strip
280
280
  {
281
281
  1 => {
282
282
  :sym => {
@@ -292,11 +292,11 @@ EOS
292
292
  end
293
293
 
294
294
  it "plain single line" do
295
- @hash.ai(:plain => true, :multiline => false).should == '{ 1 => { :sym => { "str" => { [ 1, 2, 3 ] => { { :k => :v } => Hash < Object } } } } }'
295
+ expect(@hash.ai(:plain => true, :multiline => false)).to eq('{ 1 => { :sym => { "str" => { [ 1, 2, 3 ] => { { :k => :v } => Hash < Object } } } } }')
296
296
  end
297
297
 
298
298
  it "colored multiline (default)" do
299
- @hash.ai.should == <<-EOS.strip
299
+ expect(@hash.ai).to eq <<-EOS.strip
300
300
  {
301
301
  1\e[0;37m => \e[0m{
302
302
  :sym\e[0;37m => \e[0m{
@@ -312,7 +312,7 @@ EOS
312
312
  end
313
313
 
314
314
  it "colored multiline indented" do
315
- @hash.ai(:indent => 2).should == <<-EOS.strip
315
+ expect(@hash.ai(:indent => 2)).to eq <<-EOS.strip
316
316
  {
317
317
  1\e[0;37m => \e[0m{
318
318
  :sym\e[0;37m => \e[0m{
@@ -328,7 +328,7 @@ EOS
328
328
  end
329
329
 
330
330
  it "colored single line" do
331
- @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 } } } } }"
331
+ 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 } } } } }")
332
332
  end
333
333
 
334
334
  end
@@ -341,7 +341,7 @@ EOS
341
341
  end
342
342
 
343
343
  it "plain multiline" do
344
- @hash.ai(:plain => true).should == <<-EOS.strip
344
+ expect(@hash.ai(:plain => true)).to eq <<-EOS.strip
345
345
  {
346
346
  :a => {...}
347
347
  }
@@ -349,7 +349,7 @@ EOS
349
349
  end
350
350
 
351
351
  it "plain single line" do
352
- @hash.ai(:plain => true, :multiline => false).should == '{ :a => {...} }'
352
+ expect(@hash.ai(:plain => true, :multiline => false)).to eq('{ :a => {...} }')
353
353
  end
354
354
  end
355
355
 
@@ -362,13 +362,13 @@ EOS
362
362
  it "plain multiline" do
363
363
  out = @hash.ai(:plain => true)
364
364
  if RUBY_VERSION.to_f < 1.9 # Order of @hash keys is not guaranteed.
365
- out.should =~ /^\{[^\}]+\}/m
366
- out.should =~ / "b" => "b",?/
367
- out.should =~ / :a => "a",?/
368
- out.should =~ / :z => "z",?/
369
- out.should =~ / "alpha" => "alpha",?$/
365
+ expect(out).to match(/^\{[^\}]+\}/m)
366
+ expect(out).to match(/ "b" => "b",?/)
367
+ expect(out).to match(/ :a => "a",?/)
368
+ expect(out).to match(/ :z => "z",?/)
369
+ expect(out).to match(/ "alpha" => "alpha",?$/)
370
370
  else
371
- out.should == <<-EOS.strip
371
+ expect(out).to eq <<-EOS.strip
372
372
  {
373
373
  "b" => "b",
374
374
  :a => "a",
@@ -378,9 +378,9 @@ EOS
378
378
  EOS
379
379
  end
380
380
  end
381
-
381
+
382
382
  it "plain multiline with sorted keys" do
383
- @hash.ai(:plain => true, :sort_keys => true).should == <<-EOS.strip
383
+ expect(@hash.ai(:plain => true, :sort_keys => true)).to eq <<-EOS.strip
384
384
  {
385
385
  :a => "a",
386
386
  "alpha" => "alpha",
@@ -401,7 +401,7 @@ EOS
401
401
  it "hash keys must be left aligned" do
402
402
  hash = { [0, 0, 255] => :yellow, :red => "rgb(255, 0, 0)", "magenta" => "rgb(255, 0, 255)" }
403
403
  out = hash.ai(:plain => true, :indent => -4, :sort_keys => true)
404
- out.should == <<-EOS.strip
404
+ expect(out).to eq <<-EOS.strip
405
405
  {
406
406
  [ 0, 0, 255 ] => :yellow,
407
407
  "magenta" => "rgb(255, 0, 255)",
@@ -413,7 +413,7 @@ EOS
413
413
  it "nested hash keys should be indented (array of hashes)" do
414
414
  arr = [ { :a => 1, :bb => 22, :ccc => 333}, { 1 => :a, 22 => :bb, 333 => :ccc} ]
415
415
  out = arr.ai(:plain => true, :indent => -4, :sort_keys => true)
416
- out.should == <<-EOS.strip
416
+ expect(out).to eq <<-EOS.strip
417
417
  [
418
418
  [0] {
419
419
  :a => 1,
@@ -432,7 +432,7 @@ EOS
432
432
  it "nested hash keys should be indented (hash of hashes)" do
433
433
  arr = { :first => { :a => 1, :bb => 22, :ccc => 333}, :second => { 1 => :a, 22 => :bb, 333 => :ccc} }
434
434
  out = arr.ai(:plain => true, :indent => -4, :sort_keys => true)
435
- out.should == <<-EOS.strip
435
+ expect(out).to eq <<-EOS.strip
436
436
  {
437
437
  :first => {
438
438
  :a => 1,
@@ -452,11 +452,11 @@ EOS
452
452
  #------------------------------------------------------------------------------
453
453
  describe "Class" do
454
454
  it "shoud show superclass (plain)" do
455
- self.class.ai(:plain => true).should == "#{self.class} < #{self.class.superclass}"
455
+ expect(self.class.ai(:plain => true)).to eq("#{self.class} < #{self.class.superclass}")
456
456
  end
457
457
 
458
458
  it "shoud show superclass (color)" do
459
- self.class.ai.should == "#{self.class} < #{self.class.superclass}".yellow
459
+ expect(self.class.ai).to eq("#{self.class} < #{self.class.superclass}".yellow)
460
460
  end
461
461
  end
462
462
 
@@ -464,7 +464,7 @@ EOS
464
464
  describe "File" do
465
465
  it "should display a file (plain)" do
466
466
  File.open(__FILE__, "r") do |f|
467
- f.ai(:plain => true).should == "#{f.inspect}\n" << `ls -alF #{f.path}`.chop
467
+ expect(f.ai(:plain => true)).to eq("#{f.inspect}\n" << `ls -alF #{f.path}`.chop)
468
468
  end
469
469
  end
470
470
  end
@@ -473,7 +473,7 @@ EOS
473
473
  describe "Dir" do
474
474
  it "should display a direcory (plain)" do
475
475
  Dir.open(File.dirname(__FILE__)) do |d|
476
- d.ai(:plain => true).should == "#{d.inspect}\n" << `ls -alF #{d.path}`.chop
476
+ expect(d.ai(:plain => true)).to eq("#{d.inspect}\n" << `ls -alF #{d.path}`.chop)
477
477
  end
478
478
  end
479
479
  end
@@ -482,7 +482,7 @@ EOS
482
482
  describe "BigDecimal and Rational" do
483
483
  it "should present BigDecimal object with arbitrary precision" do
484
484
  big = BigDecimal("201020102010201020102010201020102010.4")
485
- big.ai(:plain => true).should == "201020102010201020102010201020102010.4"
485
+ expect(big.ai(:plain => true)).to eq("201020102010201020102010201020102010.4")
486
486
  end
487
487
 
488
488
  it "should present Rational object with arbitrary precision" do
@@ -494,9 +494,9 @@ EOS
494
494
  # http://www.ruby-forum.com/topic/189397
495
495
  #
496
496
  if RUBY_VERSION < "1.9"
497
- out.should == "100510051005100510051005100510051005"
497
+ expect(out).to eq("100510051005100510051005100510051005")
498
498
  else
499
- out.should == "100510051005100510051005100510051005/1"
499
+ expect(out).to eq("100510051005100510051005100510051005/1")
500
500
  end
501
501
  end
502
502
  end
@@ -507,8 +507,8 @@ EOS
507
507
  ap = AwesomePrint::Inspector.new
508
508
  ap.send(:merge_options!, { :color => { :array => :black }, :indent => 0 })
509
509
  options = ap.instance_variable_get("@options")
510
- options[:color][:array].should == :black
511
- options[:indent].should == 0
510
+ expect(options[:color][:array]).to eq(:black)
511
+ expect(options[:indent]).to eq(0)
512
512
  end
513
513
  end
514
514
 
@@ -520,40 +520,40 @@ EOS
520
520
  end
521
521
 
522
522
  it "empty set" do
523
- Set.new.ai.should == [].ai
523
+ expect(Set.new.ai).to eq([].ai)
524
524
  end
525
525
 
526
526
  if RUBY_VERSION > "1.9"
527
527
  it "plain multiline" do
528
- @set.ai(:plain => true).should == @arr.ai(:plain => true)
528
+ expect(@set.ai(:plain => true)).to eq(@arr.ai(:plain => true))
529
529
  end
530
530
 
531
531
  it "plain multiline indented" do
532
- @set.ai(:plain => true, :indent => 1).should == @arr.ai(:plain => true, :indent => 1)
532
+ expect(@set.ai(:plain => true, :indent => 1)).to eq(@arr.ai(:plain => true, :indent => 1))
533
533
  end
534
534
 
535
535
  it "plain single line" do
536
- @set.ai(:plain => true, :multiline => false).should == @arr.ai(:plain => true, :multiline => false)
536
+ expect(@set.ai(:plain => true, :multiline => false)).to eq(@arr.ai(:plain => true, :multiline => false))
537
537
  end
538
538
 
539
539
  it "colored multiline (default)" do
540
- @set.ai.should == @arr.ai
540
+ expect(@set.ai).to eq(@arr.ai)
541
541
  end
542
542
  else # Prior to Ruby 1.9 the order of set values is unpredicatble.
543
543
  it "plain multiline" do
544
- @set.sort_by{ |x| x.to_s }.ai(:plain => true).should == @arr.sort_by{ |x| x.to_s }.ai(:plain => true)
544
+ expect(@set.sort_by{ |x| x.to_s }.ai(:plain => true)).to eq(@arr.sort_by{ |x| x.to_s }.ai(:plain => true))
545
545
  end
546
546
 
547
547
  it "plain multiline indented" do
548
- @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)
548
+ 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))
549
549
  end
550
550
 
551
551
  it "plain single line" do
552
- @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)
552
+ 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))
553
553
  end
554
554
 
555
555
  it "colored multiline (default)" do
556
- @set.sort_by{ |x| x.to_s }.ai.should == @arr.sort_by{ |x| x.to_s }.ai
556
+ expect(@set.sort_by{ |x| x.to_s }.ai).to eq(@arr.sort_by{ |x| x.to_s }.ai)
557
557
  end
558
558
  end
559
559
  end
@@ -569,11 +569,11 @@ EOS
569
569
  @struct.name = "Herman Munster"
570
570
  @struct.address = "1313 Mockingbird Lane"
571
571
  end
572
-
572
+
573
573
  it "empty struct" do
574
- Struct.new("EmptyStruct").ai.should == "\e[1;33mStruct::EmptyStruct < Struct\e[0m"
574
+ expect(Struct.new("EmptyStruct").ai).to eq("\e[1;33mStruct::EmptyStruct < Struct\e[0m")
575
575
  end
576
-
576
+
577
577
  it "plain multiline" do
578
578
  s1 = <<-EOS.strip
579
579
  {
@@ -587,7 +587,7 @@ EOS
587
587
  :address => "1313 Mockingbird Lane"
588
588
  }
589
589
  EOS
590
- @struct.ai(:plain => true).should satisfy { |match| match == s1 || match == s2 }
590
+ expect(@struct.ai(:plain => true)).to satisfy { |match| match == s1 || match == s2 }
591
591
  end
592
592
 
593
593
  it "plain multiline indented" do
@@ -603,13 +603,13 @@ EOS
603
603
  :address => "1313 Mockingbird Lane"
604
604
  }
605
605
  EOS
606
- @struct.ai(:plain => true, :indent => 1).should satisfy { |match| match == s1 || match == s2 }
606
+ expect(@struct.ai(:plain => true, :indent => 1)).to satisfy { |match| match == s1 || match == s2 }
607
607
  end
608
608
 
609
609
  it "plain single line" do
610
610
  s1 = "{ :address => \"1313 Mockingbird Lane\", :name => \"Herman Munster\" }"
611
611
  s2 = "{ :name => \"Herman Munster\", :address => \"1313 Mockingbird Lane\" }"
612
- @struct.ai(:plain => true, :multiline => false).should satisfy { |match| match == s1 || match == s2 }
612
+ expect(@struct.ai(:plain => true, :multiline => false)).to satisfy { |match| match == s1 || match == s2 }
613
613
  end
614
614
 
615
615
  it "colored multiline (default)" do
@@ -625,7 +625,7 @@ EOS
625
625
  :address\e[0;37m => \e[0m\e[0;33m\"1313 Mockingbird Lane\"\e[0m
626
626
  }
627
627
  EOS
628
- @struct.ai.should satisfy { |match| match == s1 || match == s2 }
628
+ expect(@struct.ai).to satisfy { |match| match == s1 || match == s2 }
629
629
  end
630
630
  end
631
631
 
@@ -639,7 +639,7 @@ EOS
639
639
  class My < Array; end
640
640
 
641
641
  my = My.new([ 1, :two, "three", [ nil, [ true, false ] ] ])
642
- my.ai(:plain => true).should == <<-EOS.strip
642
+ expect(my.ai(:plain => true)).to eq <<-EOS.strip
643
643
  [
644
644
  [0] 1,
645
645
  [1] :two,
@@ -659,7 +659,7 @@ EOS
659
659
  class My < Hash; end
660
660
 
661
661
  my = My[ { 1 => { :sym => { "str" => { [1, 2, 3] => { { :k => :v } => Hash } } } } } ]
662
- my.ai(:plain => true).should == <<-EOS.strip
662
+ expect(my.ai(:plain => true)).to eq <<-EOS.strip
663
663
  {
664
664
  1 => {
665
665
  :sym => {
@@ -678,7 +678,7 @@ EOS
678
678
  class My < File; end
679
679
 
680
680
  my = File.new('/dev/null') rescue File.new('nul')
681
- my.ai(:plain => true).should == "#{my.inspect}\n" << `ls -alF #{my.path}`.chop
681
+ expect(my.ai(:plain => true)).to eq("#{my.inspect}\n" << `ls -alF #{my.path}`.chop)
682
682
  end
683
683
 
684
684
  it "inherited from Dir should be displayed as Dir" do
@@ -686,7 +686,7 @@ EOS
686
686
 
687
687
  require 'tmpdir'
688
688
  my = My.new(Dir.tmpdir)
689
- my.ai(:plain => true).should == "#{my.inspect}\n" << `ls -alF #{my.path}`.chop
689
+ expect(my.ai(:plain => true)).to eq("#{my.inspect}\n" << `ls -alF #{my.path}`.chop)
690
690
  end
691
691
 
692
692
  it "should handle a class that defines its own #send method" do
@@ -695,7 +695,7 @@ EOS
695
695
  end
696
696
 
697
697
  my = My.new
698
- my.methods.ai(:plain => true).should_not raise_error(ArgumentError)
698
+ expect { my.methods.ai(:plain => true) }.not_to raise_error
699
699
  end
700
700
 
701
701
  it "should handle a class defines its own #method method (ex. request.method)" do
@@ -706,7 +706,7 @@ EOS
706
706
  end
707
707
 
708
708
  my = My.new
709
- my.methods.ai(:plain => true).should_not raise_error(ArgumentError)
709
+ expect { my.methods.ai(:plain => true) }.not_to raise_error
710
710
  end
711
711
  end
712
712
  end