diff --git a/.travis.yml b/.travis.yml index f2d3580..d3389de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,8 @@ gemfile: - gemfiles/rails_5.0.gemfile - gemfiles/rails_5.1.gemfile - gemfiles/rails_5.2.gemfile + - gemfiles/rails_6.0.gemfile + - gemfiles/rails_6.1.gemfile - gemfiles/mongoid_5.0.gemfile - gemfiles/mongoid_6.0.gemfile diff --git a/Appraisals b/Appraisals index a98e42a..6a24bb7 100644 --- a/Appraisals +++ b/Appraisals @@ -19,6 +19,14 @@ appraise 'rails-5.2' do gem 'rails', '>= 5.2.0', '< 5.3' end +appraise 'rails-6.0' do + gem 'rails', '>= 6.0.0', '< 6.1' +end + +appraise 'rails-6.1' do + gem 'rails', '>= 6.1.0', '< 6.2' +end + appraise 'mongoid-4.0' do gem 'mongoid', '~> 4.0.0' end diff --git a/gemfiles/rails_6.0.gemfile b/gemfiles/rails_6.0.gemfile new file mode 100644 index 0000000..3113d66 --- /dev/null +++ b/gemfiles/rails_6.0.gemfile @@ -0,0 +1,7 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "rails", ">= 6.0.0", "< 6.1" + +gemspec path: "../" diff --git a/gemfiles/rails_6.1.gemfile b/gemfiles/rails_6.1.gemfile new file mode 100644 index 0000000..8aed9cc --- /dev/null +++ b/gemfiles/rails_6.1.gemfile @@ -0,0 +1,7 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "rails", ">= 6.1.0", "< 6.2" + +gemspec path: "../" diff --git a/spec/ext/action_view_spec.rb b/spec/ext/action_view_spec.rb index c772d81..76022a3 100644 --- a/spec/ext/action_view_spec.rb +++ b/spec/ext/action_view_spec.rb @@ -1,9 +1,12 @@ require 'spec_helper' RSpec.describe 'AwesomePrint ActionView extensions', skip: -> { !ExtVerifier.has_rails? }.call do - before do - @view = ActionView::Base.new + @view = if rails_6_1? + ActionView::Base.new(ActionView::LookupContext.new([]), {}, {}) + else + ActionView::Base.new + end end it "uses HTML and adds 'debug_dump' class to plain
 tag" do
diff --git a/spec/ext/active_record_spec.rb b/spec/ext/active_record_spec.rb
index 3aab411..603632a 100644
--- a/spec/ext/active_record_spec.rb
+++ b/spec/ext/active_record_spec.rb
@@ -120,7 +120,11 @@ EOS
       out = @ap.awesome(@diana)
 
       raw_object_string =
-        if activerecord_5_2?
+        if activerecord_6_1?
+          ActiveRecordData.raw_6_1_diana
+        elsif activerecord_6_0?
+          ActiveRecordData.raw_6_0_diana
+        elsif activerecord_5_2?
           ActiveRecordData.raw_5_2_diana
         elsif activerecord_5_1?
           ActiveRecordData.raw_5_1_diana
@@ -143,7 +147,11 @@ EOS
       out = @ap.awesome([@diana, @laura])
 
       raw_object_string =
-        if activerecord_5_2?
+        if activerecord_6_1?
+          ActiveRecordData.raw_6_1_multi
+        elsif activerecord_6_0?
+          ActiveRecordData.raw_6_0_multi
+        elsif activerecord_5_2?
           ActiveRecordData.raw_5_2_multi
         elsif activerecord_5_1?
           ActiveRecordData.raw_5_1_multi
diff --git a/spec/ext/active_support_spec.rb b/spec/ext/active_support_spec.rb
index f14299d..a347161 100644
--- a/spec/ext/active_support_spec.rb
+++ b/spec/ext/active_support_spec.rb
@@ -8,7 +8,11 @@ RSpec.describe 'AwesomePrint::ActiveSupport', skip: -> { !ExtVerifier.has_rails?
   it 'should format ActiveSupport::TimeWithZone as regular Time' do
     Time.zone = 'Eastern Time (US & Canada)'
     time = Time.utc(2007, 2, 10, 20, 30, 45).in_time_zone
-    expect(@ap.send(:awesome, time)).to eq("\e[0;32mSat, 10 Feb 2007 15:30:45 EST -05:00\e[0m")
+    if activerecord_6_1?
+      expect(@ap.send(:awesome, time)).to eq("\e[0;32mSat, 10 Feb 2007 15:30:45.000000000 EST -05:00\e[0m")
+    else
+      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
diff --git a/spec/support/active_record_data/6_0_diana.txt b/spec/support/active_record_data/6_0_diana.txt
new file mode 100644
index 0000000..d3b68ef
--- /dev/null
+++ b/spec/support/active_record_data/6_0_diana.txt
@@ -0,0 +1,104 @@
+# #,
+                    attr_reader :value_before_type_cast = nil
+                >,
+                attr_reader :name = "admin",
+                attr_reader :type = #,
+                attr_reader :value_before_type_cast = false
+            >,
+            "created_at" => #,
+                    attr_reader :value_before_type_cast = nil
+                >,
+                attr_reader :name = "created_at",
+                attr_reader :type = #,
+                attr_reader :value_before_type_cast = "1992-10-10 12:30:00"
+            >,
+                    "id" => #,
+                attr_reader :value_before_type_cast = nil
+            >,
+                  "name" => #,
+                    attr_reader :value_before_type_cast = nil
+                >,
+                attr_reader :name = "name",
+                attr_reader :type = #,
+                attr_reader :value_before_type_cast = "Diana"
+            >,
+                  "rank" => #,
+                    attr_reader :value_before_type_cast = nil
+                >,
+                attr_reader :name = "rank",
+                attr_reader :type = #,
+                attr_reader :value_before_type_cast = 1
+            >
+        }
+    >,
+    attr_accessor :destroyed_by_association = nil
+>
diff --git a/spec/support/active_record_data/6_0_multi.txt b/spec/support/active_record_data/6_0_multi.txt
new file mode 100644
index 0000000..987c9da
--- /dev/null
+++ b/spec/support/active_record_data/6_0_multi.txt
@@ -0,0 +1,210 @@
+[
+    [0] # #,
+                        attr_reader :value_before_type_cast = nil
+                    >,
+                    attr_reader :name = "admin",
+                    attr_reader :type = #,
+                    attr_reader :value_before_type_cast = false
+                >,
+                "created_at" => #,
+                        attr_reader :value_before_type_cast = nil
+                    >,
+                    attr_reader :name = "created_at",
+                    attr_reader :type = #,
+                    attr_reader :value_before_type_cast = "1992-10-10 12:30:00"
+                >,
+                        "id" => #,
+                    attr_reader :value_before_type_cast = nil
+                >,
+                      "name" => #,
+                        attr_reader :value_before_type_cast = nil
+                    >,
+                    attr_reader :name = "name",
+                    attr_reader :type = #,
+                    attr_reader :value_before_type_cast = "Diana"
+                >,
+                      "rank" => #,
+                        attr_reader :value_before_type_cast = nil
+                    >,
+                    attr_reader :name = "rank",
+                    attr_reader :type = #,
+                    attr_reader :value_before_type_cast = 1
+                >
+            }
+        >,
+        attr_accessor :destroyed_by_association = nil
+    >,
+    [1] # #,
+                        attr_reader :value_before_type_cast = nil
+                    >,
+                    attr_reader :name = "admin",
+                    attr_reader :type = #,
+                    attr_reader :value_before_type_cast = true
+                >,
+                "created_at" => #,
+                        attr_reader :value_before_type_cast = nil
+                    >,
+                    attr_reader :name = "created_at",
+                    attr_reader :type = #,
+                    attr_reader :value_before_type_cast = "2003-05-26 14:15:00"
+                >,
+                        "id" => #,
+                    attr_reader :value_before_type_cast = nil
+                >,
+                      "name" => #,
+                        attr_reader :value_before_type_cast = nil
+                    >,
+                    attr_reader :name = "name",
+                    attr_reader :type = #,
+                    attr_reader :value_before_type_cast = "Laura"
+                >,
+                      "rank" => #,
+                        attr_reader :value_before_type_cast = nil
+                    >,
+                    attr_reader :name = "rank",
+                    attr_reader :type = #,
+                    attr_reader :value_before_type_cast = 2
+                >
+            }
+        >,
+        attr_accessor :destroyed_by_association = nil
+    >
+]
diff --git a/spec/support/active_record_data/6_1_diana.txt b/spec/support/active_record_data/6_1_diana.txt
new file mode 100644
index 0000000..08ca776
--- /dev/null
+++ b/spec/support/active_record_data/6_1_diana.txt
@@ -0,0 +1,109 @@
+# #,
+                    attr_reader :value_before_type_cast = nil
+                >,
+                attr_reader :name = "admin",
+                attr_reader :type = #,
+                attr_reader :value_before_type_cast = false
+            >,
+            "created_at" => #,
+                    attr_reader :value_before_type_cast = nil
+                >,
+                attr_reader :name = "created_at",
+                attr_reader :type = #,
+                attr_reader :value_before_type_cast = "1992-10-10 12:30:00"
+            >,
+                    "id" => #,
+                attr_reader :value_before_type_cast = nil
+            >,
+                  "name" => #,
+                    attr_reader :value_before_type_cast = nil
+                >,
+                attr_reader :name = "name",
+                attr_reader :type = #,
+                attr_reader :value_before_type_cast = "Diana"
+            >,
+                  "rank" => #,
+                    attr_reader :value_before_type_cast = nil
+                >,
+                attr_reader :name = "rank",
+                attr_reader :type = #,
+                attr_reader :value_before_type_cast = 1
+            >
+        }
+    >,
+    attr_accessor :destroyed_by_association = nil
+>
diff --git a/spec/support/active_record_data/6_1_multi.txt b/spec/support/active_record_data/6_1_multi.txt
new file mode 100644
index 0000000..8a25372
--- /dev/null
+++ b/spec/support/active_record_data/6_1_multi.txt
@@ -0,0 +1,220 @@
+[
+    [0] # #,
+                        attr_reader :value_before_type_cast = nil
+                    >,
+                    attr_reader :name = "admin",
+                    attr_reader :type = #,
+                    attr_reader :value_before_type_cast = false
+                >,
+                "created_at" => #,
+                        attr_reader :value_before_type_cast = nil
+                    >,
+                    attr_reader :name = "created_at",
+                    attr_reader :type = #,
+                    attr_reader :value_before_type_cast = "1992-10-10 12:30:00"
+                >,
+                        "id" => #,
+                    attr_reader :value_before_type_cast = nil
+                >,
+                      "name" => #,
+                        attr_reader :value_before_type_cast = nil
+                    >,
+                    attr_reader :name = "name",
+                    attr_reader :type = #,
+                    attr_reader :value_before_type_cast = "Diana"
+                >,
+                      "rank" => #,
+                        attr_reader :value_before_type_cast = nil
+                    >,
+                    attr_reader :name = "rank",
+                    attr_reader :type = #,
+                    attr_reader :value_before_type_cast = 1
+                >
+            }
+        >,
+        attr_accessor :destroyed_by_association = nil
+    >,
+    [1] # #,
+                        attr_reader :value_before_type_cast = nil
+                    >,
+                    attr_reader :name = "admin",
+                    attr_reader :type = #,
+                    attr_reader :value_before_type_cast = true
+                >,
+                "created_at" => #,
+                        attr_reader :value_before_type_cast = nil
+                    >,
+                    attr_reader :name = "created_at",
+                    attr_reader :type = #,
+                    attr_reader :value_before_type_cast = "2003-05-26 14:15:00"
+                >,
+                        "id" => #,
+                    attr_reader :value_before_type_cast = nil
+                >,
+                      "name" => #,
+                        attr_reader :value_before_type_cast = nil
+                    >,
+                    attr_reader :name = "name",
+                    attr_reader :type = #,
+                    attr_reader :value_before_type_cast = "Laura"
+                >,
+                      "rank" => #,
+                        attr_reader :value_before_type_cast = nil
+                    >,
+                    attr_reader :name = "rank",
+                    attr_reader :type = #,
+                    attr_reader :value_before_type_cast = 2
+                >
+            }
+        >,
+        attr_accessor :destroyed_by_association = nil
+    >
+]
diff --git a/spec/support/rails_versions.rb b/spec/support/rails_versions.rb
index e6c6d1f..fd1662e 100644
--- a/spec/support/rails_versions.rb
+++ b/spec/support/rails_versions.rb
@@ -3,6 +3,16 @@ module RailsVersions
     Gem::Version.new(Rails::VERSION::STRING)
   end
 
+  def rails_6_1?
+    Gem::Requirement.new('~> 6.1.0').satisfied_by?(rails_version)
+  end
+  alias_method :activerecord_6_1?, :rails_6_1?
+
+  def rails_6_0?
+    Gem::Requirement.new('~> 6.0.0').satisfied_by?(rails_version)
+  end
+  alias_method :activerecord_6_0?, :rails_6_0?
+
   def rails_5_2?
     Gem::Requirement.new('~> 5.2.0').satisfied_by?(rails_version)
   end