mirror of
https://github.com/awesome-print/awesome_print
synced 2023-03-27 23:22:34 -04:00
Add tests for Rails 5
This commit is contained in:
parent
add36cf98a
commit
cde91abe6b
7 changed files with 353 additions and 3 deletions
14
.travis.yml
14
.travis.yml
|
@ -3,7 +3,8 @@ rvm:
|
|||
- 1.9.3
|
||||
- 2.0.0
|
||||
- 2.1
|
||||
- 2.2
|
||||
- 2.2.5
|
||||
- 2.3.1
|
||||
|
||||
before_install:
|
||||
- gem install bundler
|
||||
|
@ -13,9 +14,20 @@ gemfile:
|
|||
- gemfiles/rails_4.0.gemfile
|
||||
- gemfiles/rails_4.1.gemfile
|
||||
- gemfiles/rails_4.2.gemfile
|
||||
- gemfiles/rails_5.0.gemfile
|
||||
- gemfiles/mongoid_3.1.gemfile
|
||||
- gemfiles/nobrainer.gemfile
|
||||
|
||||
matrix:
|
||||
exclude:
|
||||
# Rails 5.0 only works with Ruby >= 2.2
|
||||
- rvm: 1.9.3
|
||||
gemfile: gemfiles/rails_5.0.gemfile
|
||||
- rvm: 2.0.0
|
||||
gemfile: gemfiles/rails_5.0.gemfile
|
||||
- rvm: 2.1
|
||||
gemfile: gemfiles/rails_5.0.gemfile
|
||||
|
||||
addons:
|
||||
code_climate:
|
||||
repo_token: 177e04fc590139a13502e44a2628979c4e8b94acdb10c78af7c6f913ef7950bd
|
||||
|
|
|
@ -26,6 +26,11 @@ appraise 'rails-4.2' do
|
|||
gem 'mime-types', '2.6.2', :platforms => :ruby_19
|
||||
end
|
||||
|
||||
appraise 'rails-5.0' do
|
||||
# Only works with Ruby >= 2.2
|
||||
gem 'rails', '>= 5.0.0.racecar1', '< 5.1'
|
||||
end
|
||||
|
||||
appraise 'mongoid-3.0' do
|
||||
gem 'mongoid', '~> 3.0.0'
|
||||
end
|
||||
|
|
7
gemfiles/rails_5.0.gemfile
Normal file
7
gemfiles/rails_5.0.gemfile
Normal file
|
@ -0,0 +1,7 @@
|
|||
# This file was generated by Appraisal
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem "rails", ">= 5.0.0.racecar1", "< 5.1"
|
||||
|
||||
gemspec :path => "../"
|
|
@ -111,7 +111,9 @@ RSpec.describe "AwesomePrint/ActiveRecord", skip: ->{ !ExtVerifier.has_rails? }.
|
|||
out = @ap.awesome(@diana)
|
||||
|
||||
raw_object_string =
|
||||
if activerecord_4_2?
|
||||
if activerecord_5_0?
|
||||
ActiveRecordData.raw_5_0_diana
|
||||
elsif activerecord_4_2?
|
||||
if RUBY_VERSION > '1.9.3'
|
||||
ActiveRecordData.raw_4_2_diana
|
||||
else
|
||||
|
@ -136,7 +138,9 @@ RSpec.describe "AwesomePrint/ActiveRecord", skip: ->{ !ExtVerifier.has_rails? }.
|
|||
out = @ap.awesome([ @diana, @laura ])
|
||||
|
||||
raw_object_string =
|
||||
if activerecord_4_2?
|
||||
if activerecord_5_0?
|
||||
ActiveRecordData.raw_5_0_multi
|
||||
elsif activerecord_4_2?
|
||||
if RUBY_VERSION > '1.9.3'
|
||||
ActiveRecordData.raw_4_2_multi
|
||||
else
|
||||
|
|
105
spec/support/active_record_data/5_0_diana.txt
Normal file
105
spec/support/active_record_data/5_0_diana.txt
Normal file
|
@ -0,0 +1,105 @@
|
|||
#<User:placeholder_id
|
||||
@_start_transaction_state = {},
|
||||
@aggregation_cache = {},
|
||||
@association_cache = {},
|
||||
@destroyed = false,
|
||||
@marked_for_destruction = false,
|
||||
@new_record = true,
|
||||
@readonly = false,
|
||||
@transaction_state = nil,
|
||||
@txn = nil,
|
||||
attr_accessor :attributes = #<ActiveRecord::AttributeSet:placeholder_id
|
||||
@attributes = {
|
||||
"admin" => #<ActiveRecord::Attribute::FromUser:placeholder_id
|
||||
@original_attribute = #<ActiveRecord::Attribute::FromDatabase:placeholder_id
|
||||
@original_attribute = nil,
|
||||
attr_reader :name = "admin",
|
||||
attr_reader :type = #<ActiveModel::Type::Boolean:placeholder_id
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = nil
|
||||
>,
|
||||
attr_reader :name = "admin",
|
||||
attr_reader :type = #<ActiveModel::Type::Boolean:placeholder_id
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = false
|
||||
>,
|
||||
"created_at" => #<ActiveRecord::Attribute::FromUser:placeholder_id
|
||||
@original_attribute = #<ActiveRecord::Attribute::FromDatabase:placeholder_id
|
||||
@original_attribute = nil,
|
||||
attr_reader :name = "created_at",
|
||||
attr_reader :type = #<ActiveRecord::Type::DateTime:placeholder_id
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = nil
|
||||
>,
|
||||
attr_reader :name = "created_at",
|
||||
attr_reader :type = #<ActiveRecord::Type::DateTime:placeholder_id
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = "1992-10-10 12:30:00"
|
||||
>,
|
||||
"id" => #<ActiveRecord::Attribute::FromDatabase:placeholder_id
|
||||
@original_attribute = nil,
|
||||
attr_reader :name = "id",
|
||||
attr_reader :type = #<ActiveModel::Type::Integer:placeholder_id
|
||||
@range = -2147483648...2147483648,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = nil
|
||||
>,
|
||||
"name" => #<ActiveRecord::Attribute::FromUser:placeholder_id
|
||||
@original_attribute = #<ActiveRecord::Attribute::FromDatabase:placeholder_id
|
||||
@original_attribute = nil,
|
||||
attr_reader :name = "name",
|
||||
attr_reader :type = #<ActiveModel::Type::String:placeholder_id
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = nil
|
||||
>,
|
||||
attr_reader :name = "name",
|
||||
attr_reader :type = #<ActiveModel::Type::String:placeholder_id
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = "Diana"
|
||||
>,
|
||||
"rank" => #<ActiveRecord::Attribute::FromUser:placeholder_id
|
||||
@original_attribute = #<ActiveRecord::Attribute::FromDatabase:placeholder_id
|
||||
@original_attribute = nil,
|
||||
attr_reader :name = "rank",
|
||||
attr_reader :type = #<ActiveModel::Type::Integer:placeholder_id
|
||||
@range = -2147483648...2147483648,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = nil
|
||||
>,
|
||||
attr_reader :name = "rank",
|
||||
attr_reader :type = #<ActiveModel::Type::Integer:placeholder_id
|
||||
@range = -2147483648...2147483648,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = 1
|
||||
>
|
||||
}
|
||||
>,
|
||||
attr_accessor :destroyed_by_association = nil
|
||||
>
|
212
spec/support/active_record_data/5_0_multi.txt
Normal file
212
spec/support/active_record_data/5_0_multi.txt
Normal file
|
@ -0,0 +1,212 @@
|
|||
[
|
||||
[0] #<User:placeholder_id
|
||||
@_start_transaction_state = {},
|
||||
@aggregation_cache = {},
|
||||
@association_cache = {},
|
||||
@destroyed = false,
|
||||
@marked_for_destruction = false,
|
||||
@new_record = true,
|
||||
@readonly = false,
|
||||
@transaction_state = nil,
|
||||
@txn = nil,
|
||||
attr_accessor :attributes = #<ActiveRecord::AttributeSet:placeholder_id
|
||||
@attributes = {
|
||||
"admin" => #<ActiveRecord::Attribute::FromUser:placeholder_id
|
||||
@original_attribute = #<ActiveRecord::Attribute::FromDatabase:placeholder_id
|
||||
@original_attribute = nil,
|
||||
attr_reader :name = "admin",
|
||||
attr_reader :type = #<ActiveModel::Type::Boolean:placeholder_id
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = nil
|
||||
>,
|
||||
attr_reader :name = "admin",
|
||||
attr_reader :type = #<ActiveModel::Type::Boolean:placeholder_id
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = false
|
||||
>,
|
||||
"created_at" => #<ActiveRecord::Attribute::FromUser:placeholder_id
|
||||
@original_attribute = #<ActiveRecord::Attribute::FromDatabase:placeholder_id
|
||||
@original_attribute = nil,
|
||||
attr_reader :name = "created_at",
|
||||
attr_reader :type = #<ActiveRecord::Type::DateTime:placeholder_id
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = nil
|
||||
>,
|
||||
attr_reader :name = "created_at",
|
||||
attr_reader :type = #<ActiveRecord::Type::DateTime:placeholder_id
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = "1992-10-10 12:30:00"
|
||||
>,
|
||||
"id" => #<ActiveRecord::Attribute::FromDatabase:placeholder_id
|
||||
@original_attribute = nil,
|
||||
attr_reader :name = "id",
|
||||
attr_reader :type = #<ActiveModel::Type::Integer:placeholder_id
|
||||
@range = -2147483648...2147483648,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = nil
|
||||
>,
|
||||
"name" => #<ActiveRecord::Attribute::FromUser:placeholder_id
|
||||
@original_attribute = #<ActiveRecord::Attribute::FromDatabase:placeholder_id
|
||||
@original_attribute = nil,
|
||||
attr_reader :name = "name",
|
||||
attr_reader :type = #<ActiveModel::Type::String:placeholder_id
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = nil
|
||||
>,
|
||||
attr_reader :name = "name",
|
||||
attr_reader :type = #<ActiveModel::Type::String:placeholder_id
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = "Diana"
|
||||
>,
|
||||
"rank" => #<ActiveRecord::Attribute::FromUser:placeholder_id
|
||||
@original_attribute = #<ActiveRecord::Attribute::FromDatabase:placeholder_id
|
||||
@original_attribute = nil,
|
||||
attr_reader :name = "rank",
|
||||
attr_reader :type = #<ActiveModel::Type::Integer:placeholder_id
|
||||
@range = -2147483648...2147483648,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = nil
|
||||
>,
|
||||
attr_reader :name = "rank",
|
||||
attr_reader :type = #<ActiveModel::Type::Integer:placeholder_id
|
||||
@range = -2147483648...2147483648,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = 1
|
||||
>
|
||||
}
|
||||
>,
|
||||
attr_accessor :destroyed_by_association = nil
|
||||
>,
|
||||
[1] #<User:placeholder_id
|
||||
@_start_transaction_state = {},
|
||||
@aggregation_cache = {},
|
||||
@association_cache = {},
|
||||
@destroyed = false,
|
||||
@marked_for_destruction = false,
|
||||
@new_record = true,
|
||||
@readonly = false,
|
||||
@transaction_state = nil,
|
||||
@txn = nil,
|
||||
attr_accessor :attributes = #<ActiveRecord::AttributeSet:placeholder_id
|
||||
@attributes = {
|
||||
"admin" => #<ActiveRecord::Attribute::FromUser:placeholder_id
|
||||
@original_attribute = #<ActiveRecord::Attribute::FromDatabase:placeholder_id
|
||||
@original_attribute = nil,
|
||||
attr_reader :name = "admin",
|
||||
attr_reader :type = #<ActiveModel::Type::Boolean:placeholder_id
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = nil
|
||||
>,
|
||||
attr_reader :name = "admin",
|
||||
attr_reader :type = #<ActiveModel::Type::Boolean:placeholder_id
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = true
|
||||
>,
|
||||
"created_at" => #<ActiveRecord::Attribute::FromUser:placeholder_id
|
||||
@original_attribute = #<ActiveRecord::Attribute::FromDatabase:placeholder_id
|
||||
@original_attribute = nil,
|
||||
attr_reader :name = "created_at",
|
||||
attr_reader :type = #<ActiveRecord::Type::DateTime:placeholder_id
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = nil
|
||||
>,
|
||||
attr_reader :name = "created_at",
|
||||
attr_reader :type = #<ActiveRecord::Type::DateTime:placeholder_id
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = "2003-05-26 14:15:00"
|
||||
>,
|
||||
"id" => #<ActiveRecord::Attribute::FromDatabase:placeholder_id
|
||||
@original_attribute = nil,
|
||||
attr_reader :name = "id",
|
||||
attr_reader :type = #<ActiveModel::Type::Integer:placeholder_id
|
||||
@range = -2147483648...2147483648,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = nil
|
||||
>,
|
||||
"name" => #<ActiveRecord::Attribute::FromUser:placeholder_id
|
||||
@original_attribute = #<ActiveRecord::Attribute::FromDatabase:placeholder_id
|
||||
@original_attribute = nil,
|
||||
attr_reader :name = "name",
|
||||
attr_reader :type = #<ActiveModel::Type::String:placeholder_id
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = nil
|
||||
>,
|
||||
attr_reader :name = "name",
|
||||
attr_reader :type = #<ActiveModel::Type::String:placeholder_id
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = "Laura"
|
||||
>,
|
||||
"rank" => #<ActiveRecord::Attribute::FromUser:placeholder_id
|
||||
@original_attribute = #<ActiveRecord::Attribute::FromDatabase:placeholder_id
|
||||
@original_attribute = nil,
|
||||
attr_reader :name = "rank",
|
||||
attr_reader :type = #<ActiveModel::Type::Integer:placeholder_id
|
||||
@range = -2147483648...2147483648,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = nil
|
||||
>,
|
||||
attr_reader :name = "rank",
|
||||
attr_reader :type = #<ActiveModel::Type::Integer:placeholder_id
|
||||
@range = -2147483648...2147483648,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value_before_type_cast = 2
|
||||
>
|
||||
}
|
||||
>,
|
||||
attr_accessor :destroyed_by_association = nil
|
||||
>
|
||||
]
|
|
@ -3,6 +3,11 @@ module RailsVersions
|
|||
Gem::Version.new(Rails::VERSION::STRING)
|
||||
end
|
||||
|
||||
def rails_5_0?
|
||||
Gem::Requirement.new('~> 5.0.0.racecar1').satisfied_by?(rails_version)
|
||||
end
|
||||
alias_method :activerecord_5_0?, :rails_5_0?
|
||||
|
||||
def rails_4_2?
|
||||
Gem::Requirement.new('~> 4.2.0').satisfied_by?(rails_version)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue