mirror of
https://github.com/awesome-print/awesome_print
synced 2023-03-27 23:22:34 -04:00
Fix broken specs
Fix specs on all gemfiles. Removed some specs related to version before of ActiveRecord 3.2.
This commit is contained in:
parent
0d8b123864
commit
e62397c2bb
4 changed files with 718 additions and 159 deletions
|
@ -27,14 +27,6 @@ class SubUser < User; end
|
|||
# Helper methods
|
||||
# ##############
|
||||
|
||||
def activerecord_version
|
||||
# ActiveRecord 4+
|
||||
return ActiveRecord.version.to_s if ActiveRecord.method_defined? :version
|
||||
|
||||
# everything else
|
||||
ActiveRecord::VERSION::STRING
|
||||
end
|
||||
|
||||
# we only work with ActiveRecord 2+
|
||||
def is_usable_activerecord?
|
||||
defined?(ActiveRecord::VERSION::MAJOR) && ActiveRecord::VERSION::MAJOR >= 2
|
||||
|
|
|
@ -82,7 +82,133 @@ EOS
|
|||
it "display single record" do
|
||||
out = @ap.send(:awesome, @diana)
|
||||
|
||||
if activerecord_version >= "4.1"
|
||||
if activerecord_4_2?
|
||||
str = <<-EOS.strip
|
||||
#<User:0x01234567
|
||||
@_start_transaction_state = {},
|
||||
@aggregation_cache = {},
|
||||
@destroyed = false,
|
||||
@marked_for_destruction = false,
|
||||
@new_record = true,
|
||||
@original_raw_attributes = {
|
||||
"admin" => false,
|
||||
"created_at" => 1992-10-10 12:30:00 UTC,
|
||||
"name" => "Diana",
|
||||
"rank" => 1
|
||||
},
|
||||
@readonly = false,
|
||||
@reflects_state = [
|
||||
[0] false
|
||||
],
|
||||
@transaction_state = nil,
|
||||
@txn = nil,
|
||||
attr_accessor :attributes = #<ActiveRecord::AttributeSet:0x01234567
|
||||
@attributes = #<ActiveRecord::LazyAttributeHash:0x01234567
|
||||
@additional_types = {},
|
||||
@delegate_hash = {
|
||||
"admin" => #<ActiveRecord::Attribute::FromUser:0x01234567
|
||||
attr_reader :name = "admin",
|
||||
attr_reader :type = #<ActiveRecord::Type::Boolean:0x01234567
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value = false,
|
||||
attr_reader :value_before_type_cast = false
|
||||
>,
|
||||
"created_at" => #<ActiveRecord::Attribute::FromUser:0x01234567
|
||||
attr_reader :name = "created_at",
|
||||
attr_reader :type = #<ActiveRecord::Type::DateTime:0x01234567
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value = 1992-10-10 12:30:00 UTC,
|
||||
attr_reader :value_before_type_cast = "1992-10-10 12:30:00"
|
||||
>,
|
||||
"id" => #<ActiveRecord::Attribute::FromDatabase:0x01234567
|
||||
attr_reader :name = "id",
|
||||
attr_reader :type = #<ActiveRecord::Type::Integer:0x01234567
|
||||
@range = -2147483648...2147483648,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value = nil,
|
||||
attr_reader :value_before_type_cast = nil
|
||||
>,
|
||||
"name" => #<ActiveRecord::Attribute::FromUser:0x01234567
|
||||
attr_reader :name = "name",
|
||||
attr_reader :type = #<ActiveRecord::ConnectionAdapters::SQLite3String:0x01234567
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value = "Diana",
|
||||
attr_reader :value_before_type_cast = "Diana"
|
||||
>,
|
||||
"rank" => #<ActiveRecord::Attribute::FromUser:0x01234567
|
||||
attr_reader :name = "rank",
|
||||
attr_reader :type = #<ActiveRecord::Type::Integer:0x01234567
|
||||
@range = -2147483648...2147483648,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value = 1,
|
||||
attr_reader :value_before_type_cast = 1
|
||||
>
|
||||
},
|
||||
@materialized = false,
|
||||
@types = {
|
||||
"admin" => #<ActiveRecord::Type::Boolean:0x01234567
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
"created_at" => #<ActiveRecord::Type::DateTime:0x01234567
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
"id" => #<ActiveRecord::Type::Integer:0x01234567
|
||||
@range = -2147483648...2147483648,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
"name" => #<ActiveRecord::ConnectionAdapters::SQLite3String:0x01234567
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
"rank" => #<ActiveRecord::Type::Integer:0x01234567
|
||||
@range = -2147483648...2147483648,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>
|
||||
},
|
||||
@values = {
|
||||
"admin" => nil,
|
||||
"created_at" => nil,
|
||||
"id" => nil,
|
||||
"name" => nil,
|
||||
"rank" => nil
|
||||
}
|
||||
>
|
||||
>,
|
||||
attr_accessor :destroyed_by_association = nil,
|
||||
attr_reader :association_cache = {},
|
||||
attr_reader :changed_attributes = {
|
||||
"admin" => nil,
|
||||
"created_at" => nil,
|
||||
"name" => nil,
|
||||
"rank" => nil
|
||||
}
|
||||
>
|
||||
EOS
|
||||
elsif activerecord_4_1?
|
||||
str = <<-EOS.strip
|
||||
#<User:0x01234567
|
||||
@_start_transaction_state = {},
|
||||
|
@ -182,20 +308,118 @@ EOS
|
|||
}
|
||||
>
|
||||
EOS
|
||||
|
||||
# ActiveRecord 3.1 and on.
|
||||
#--------------------------------------------------------------------------
|
||||
elsif activerecord_version >= "3.1"
|
||||
elsif activerecord_4_0?
|
||||
str = <<-EOS.strip
|
||||
#<User:0x01234567
|
||||
@_start_transaction_state = {},
|
||||
@aggregation_cache = {},
|
||||
@attributes_cache = {},
|
||||
@column_types = {
|
||||
"admin" => #<ActiveRecord::ConnectionAdapters::SQLite3Column:0x01234567
|
||||
attr_accessor :coder = nil,
|
||||
attr_accessor :primary = false,
|
||||
attr_reader :default = nil,
|
||||
attr_reader :default_function = nil,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :name = "admin",
|
||||
attr_reader :null = true,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil,
|
||||
attr_reader :sql_type = "boolean",
|
||||
attr_reader :type = :boolean
|
||||
>,
|
||||
"created_at" => #<ActiveRecord::ConnectionAdapters::SQLite3Column:0x01234567
|
||||
attr_accessor :coder = nil,
|
||||
attr_accessor :primary = false,
|
||||
attr_reader :default = nil,
|
||||
attr_reader :default_function = nil,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :name = "created_at",
|
||||
attr_reader :null = true,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil,
|
||||
attr_reader :sql_type = "datetime",
|
||||
attr_reader :type = :datetime
|
||||
>,
|
||||
"id" => #<ActiveRecord::ConnectionAdapters::SQLite3Column:0x01234567
|
||||
attr_accessor :coder = nil,
|
||||
attr_accessor :primary = true,
|
||||
attr_reader :default = nil,
|
||||
attr_reader :default_function = nil,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :name = "id",
|
||||
attr_reader :null = false,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil,
|
||||
attr_reader :sql_type = "INTEGER",
|
||||
attr_reader :type = :integer
|
||||
>,
|
||||
"name" => #<ActiveRecord::ConnectionAdapters::SQLite3Column:0x01234567
|
||||
attr_accessor :coder = nil,
|
||||
attr_accessor :primary = false,
|
||||
attr_reader :default = nil,
|
||||
attr_reader :default_function = nil,
|
||||
attr_reader :limit = 255,
|
||||
attr_reader :name = "name",
|
||||
attr_reader :null = true,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil,
|
||||
attr_reader :sql_type = "varchar(255)",
|
||||
attr_reader :type = :string
|
||||
>,
|
||||
"rank" => #<ActiveRecord::ConnectionAdapters::SQLite3Column:0x01234567
|
||||
attr_accessor :coder = nil,
|
||||
attr_accessor :primary = false,
|
||||
attr_reader :default = nil,
|
||||
attr_reader :default_function = nil,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :name = "rank",
|
||||
attr_reader :null = true,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil,
|
||||
attr_reader :sql_type = "integer",
|
||||
attr_reader :type = :integer
|
||||
>
|
||||
},
|
||||
@column_types_override = nil,
|
||||
@destroyed = false,
|
||||
@marked_for_destruction = false,
|
||||
@new_record = true,
|
||||
@previously_changed = {},
|
||||
@readonly = false,
|
||||
@reflects_state = [
|
||||
[0] false
|
||||
],
|
||||
@transaction_state = nil,
|
||||
@txn = nil,
|
||||
attr_accessor :attributes = {
|
||||
"admin" => false,
|
||||
"created_at" => "1992-10-10 12:30:00",
|
||||
"id" => nil,
|
||||
"name" => "Diana",
|
||||
"rank" => 1
|
||||
},
|
||||
attr_accessor :destroyed_by_association = nil,
|
||||
attr_reader :association_cache = {},
|
||||
attr_reader :changed_attributes = {
|
||||
"admin" => nil,
|
||||
"created_at" => nil,
|
||||
"name" => nil,
|
||||
"rank" => nil
|
||||
}
|
||||
>
|
||||
EOS
|
||||
elsif activerecord_3_2?
|
||||
str = <<-EOS.strip
|
||||
#<User:0x01234567
|
||||
@aggregation_cache = {},
|
||||
@attributes_cache = {},
|
||||
@destroyed = false,
|
||||
@marked_for_destruction = false,
|
||||
@mass_assignment_options = nil,
|
||||
@new_record = true,
|
||||
@previously_changed = {},
|
||||
@readonly = false,
|
||||
@relation = nil,
|
||||
attr_accessor :attributes = {
|
||||
"admin" => false,
|
||||
"created_at" => "1992-10-10 12:30:00",
|
||||
|
@ -209,53 +433,6 @@ EOS
|
|||
"created_at" => nil,
|
||||
"name" => nil,
|
||||
"rank" => nil
|
||||
},
|
||||
attr_reader :mass_assignment_options = nil
|
||||
>
|
||||
EOS
|
||||
# ActiveRecord 3.0.x
|
||||
#--------------------------------------------------------------------------
|
||||
elsif activerecord_version.start_with?('3.0')
|
||||
str = <<-EOS.strip
|
||||
#<User:0x01234567
|
||||
@attributes_cache = {},
|
||||
@destroyed = false,
|
||||
@marked_for_destruction = false,
|
||||
@new_record = true,
|
||||
@previously_changed = {},
|
||||
@readonly = false,
|
||||
attr_accessor :attributes = {
|
||||
"admin" => false,
|
||||
"created_at" => "?",
|
||||
"name" => "Diana",
|
||||
"rank" => 1
|
||||
},
|
||||
attr_reader :changed_attributes = {
|
||||
"admin" => nil,
|
||||
"created_at" => nil,
|
||||
"name" => nil,
|
||||
"rank" => nil
|
||||
}
|
||||
>
|
||||
EOS
|
||||
# ActiveRecord 2.x
|
||||
#--------------------------------------------------------------------------
|
||||
elsif activerecord_version.start_with?('2.')
|
||||
str = <<-EOS.strip
|
||||
#<User:0x01234567
|
||||
@attributes_cache = {},
|
||||
@changed_attributes = {
|
||||
"admin" => nil,
|
||||
"created_at" => nil,
|
||||
"name" => nil,
|
||||
"rank" => nil
|
||||
},
|
||||
@new_record = true,
|
||||
attr_accessor :attributes = {
|
||||
"admin" => false,
|
||||
"created_at" => "1992-10-10 12:30:00",
|
||||
"name" => "Diana",
|
||||
"rank" => 1
|
||||
}
|
||||
>
|
||||
EOS
|
||||
|
@ -267,7 +444,258 @@ EOS
|
|||
it "display multiple records" do
|
||||
out = @ap.send(:awesome, [ @diana, @laura ])
|
||||
|
||||
if activerecord_version >= "4.1"
|
||||
if activerecord_4_2?
|
||||
str = <<-EOS.strip
|
||||
[
|
||||
[0] #<User:0x01234567
|
||||
@_start_transaction_state = {},
|
||||
@aggregation_cache = {},
|
||||
@destroyed = false,
|
||||
@marked_for_destruction = false,
|
||||
@new_record = true,
|
||||
@original_raw_attributes = {
|
||||
"admin" => false,
|
||||
"created_at" => 1992-10-10 12:30:00 UTC,
|
||||
"name" => "Diana",
|
||||
"rank" => 1
|
||||
},
|
||||
@readonly = false,
|
||||
@reflects_state = [
|
||||
[0] false
|
||||
],
|
||||
@transaction_state = nil,
|
||||
@txn = nil,
|
||||
attr_accessor :attributes = #<ActiveRecord::AttributeSet:0x01234567
|
||||
@attributes = #<ActiveRecord::LazyAttributeHash:0x01234567
|
||||
@additional_types = {},
|
||||
@delegate_hash = {
|
||||
"admin" => #<ActiveRecord::Attribute::FromUser:0x01234567
|
||||
attr_reader :name = "admin",
|
||||
attr_reader :type = #<ActiveRecord::Type::Boolean:0x01234567
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value = false,
|
||||
attr_reader :value_before_type_cast = false
|
||||
>,
|
||||
"created_at" => #<ActiveRecord::Attribute::FromUser:0x01234567
|
||||
attr_reader :name = "created_at",
|
||||
attr_reader :type = #<ActiveRecord::Type::DateTime:0x01234567
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value = 1992-10-10 12:30:00 UTC,
|
||||
attr_reader :value_before_type_cast = "1992-10-10 12:30:00"
|
||||
>,
|
||||
"id" => #<ActiveRecord::Attribute::FromDatabase:0x01234567
|
||||
attr_reader :name = "id",
|
||||
attr_reader :type = #<ActiveRecord::Type::Integer:0x01234567
|
||||
@range = -2147483648...2147483648,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value = nil,
|
||||
attr_reader :value_before_type_cast = nil
|
||||
>,
|
||||
"name" => #<ActiveRecord::Attribute::FromUser:0x01234567
|
||||
attr_reader :name = "name",
|
||||
attr_reader :type = #<ActiveRecord::ConnectionAdapters::SQLite3String:0x01234567
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value = "Diana",
|
||||
attr_reader :value_before_type_cast = "Diana"
|
||||
>,
|
||||
"rank" => #<ActiveRecord::Attribute::FromUser:0x01234567
|
||||
attr_reader :name = "rank",
|
||||
attr_reader :type = #<ActiveRecord::Type::Integer:0x01234567
|
||||
@range = -2147483648...2147483648,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value = 1,
|
||||
attr_reader :value_before_type_cast = 1
|
||||
>
|
||||
},
|
||||
@materialized = false,
|
||||
@types = {
|
||||
"admin" => #<ActiveRecord::Type::Boolean:0x01234567
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
"created_at" => #<ActiveRecord::Type::DateTime:0x01234567
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
"id" => #<ActiveRecord::Type::Integer:0x01234567
|
||||
@range = -2147483648...2147483648,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
"name" => #<ActiveRecord::ConnectionAdapters::SQLite3String:0x01234567
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
"rank" => #<ActiveRecord::Type::Integer:0x01234567
|
||||
@range = -2147483648...2147483648,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>
|
||||
},
|
||||
@values = {
|
||||
"admin" => nil,
|
||||
"created_at" => nil,
|
||||
"id" => nil,
|
||||
"name" => nil,
|
||||
"rank" => nil
|
||||
}
|
||||
>
|
||||
>,
|
||||
attr_accessor :destroyed_by_association = nil,
|
||||
attr_reader :association_cache = {},
|
||||
attr_reader :changed_attributes = {
|
||||
"admin" => nil,
|
||||
"created_at" => nil,
|
||||
"name" => nil,
|
||||
"rank" => nil
|
||||
}
|
||||
>,
|
||||
[1] #<User:0x01234567
|
||||
@_start_transaction_state = {},
|
||||
@aggregation_cache = {},
|
||||
@destroyed = false,
|
||||
@marked_for_destruction = false,
|
||||
@new_record = true,
|
||||
@original_raw_attributes = {
|
||||
"admin" => true,
|
||||
"created_at" => 2003-05-26 14:15:00 UTC,
|
||||
"name" => "Laura",
|
||||
"rank" => 2
|
||||
},
|
||||
@readonly = false,
|
||||
@reflects_state = [
|
||||
[0] false
|
||||
],
|
||||
@transaction_state = nil,
|
||||
@txn = nil,
|
||||
attr_accessor :attributes = #<ActiveRecord::AttributeSet:0x01234567
|
||||
@attributes = #<ActiveRecord::LazyAttributeHash:0x01234567
|
||||
@additional_types = {},
|
||||
@delegate_hash = {
|
||||
"admin" => #<ActiveRecord::Attribute::FromUser:0x01234567
|
||||
attr_reader :name = "admin",
|
||||
attr_reader :type = #<ActiveRecord::Type::Boolean:0x01234567
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value = true,
|
||||
attr_reader :value_before_type_cast = true
|
||||
>,
|
||||
"created_at" => #<ActiveRecord::Attribute::FromUser:0x01234567
|
||||
attr_reader :name = "created_at",
|
||||
attr_reader :type = #<ActiveRecord::Type::DateTime:0x01234567
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value = 2003-05-26 14:15:00 UTC,
|
||||
attr_reader :value_before_type_cast = "2003-05-26 14:15:00"
|
||||
>,
|
||||
"id" => #<ActiveRecord::Attribute::FromDatabase:0x01234567
|
||||
attr_reader :name = "id",
|
||||
attr_reader :type = #<ActiveRecord::Type::Integer:0x01234567
|
||||
@range = -2147483648...2147483648,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value = nil,
|
||||
attr_reader :value_before_type_cast = nil
|
||||
>,
|
||||
"name" => #<ActiveRecord::Attribute::FromUser:0x01234567
|
||||
attr_reader :name = "name",
|
||||
attr_reader :type = #<ActiveRecord::ConnectionAdapters::SQLite3String:0x01234567
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value = "Laura",
|
||||
attr_reader :value_before_type_cast = "Laura"
|
||||
>,
|
||||
"rank" => #<ActiveRecord::Attribute::FromUser:0x01234567
|
||||
attr_reader :name = "rank",
|
||||
attr_reader :type = #<ActiveRecord::Type::Integer:0x01234567
|
||||
@range = -2147483648...2147483648,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
attr_reader :value = 2,
|
||||
attr_reader :value_before_type_cast = 2
|
||||
>
|
||||
},
|
||||
@materialized = false,
|
||||
@types = {
|
||||
"admin" => #<ActiveRecord::Type::Boolean:0x01234567
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
"created_at" => #<ActiveRecord::Type::DateTime:0x01234567
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
"id" => #<ActiveRecord::Type::Integer:0x01234567
|
||||
@range = -2147483648...2147483648,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
"name" => #<ActiveRecord::ConnectionAdapters::SQLite3String:0x01234567
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>,
|
||||
"rank" => #<ActiveRecord::Type::Integer:0x01234567
|
||||
@range = -2147483648...2147483648,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil
|
||||
>
|
||||
},
|
||||
@values = {
|
||||
"admin" => nil,
|
||||
"created_at" => nil,
|
||||
"id" => nil,
|
||||
"name" => nil,
|
||||
"rank" => nil
|
||||
}
|
||||
>
|
||||
>,
|
||||
attr_accessor :destroyed_by_association = nil,
|
||||
attr_reader :association_cache = {},
|
||||
attr_reader :changed_attributes = {
|
||||
"admin" => nil,
|
||||
"created_at" => nil,
|
||||
"name" => nil,
|
||||
"rank" => nil
|
||||
}
|
||||
>
|
||||
]
|
||||
EOS
|
||||
elsif activerecord_4_1?
|
||||
str = <<-EOS.strip
|
||||
[
|
||||
[0] #<User:0x01234567
|
||||
|
@ -466,7 +894,208 @@ EOS
|
|||
>
|
||||
]
|
||||
EOS
|
||||
elsif ActiveRecord::VERSION::STRING >= "3.1"
|
||||
elsif activerecord_4_0?
|
||||
str = <<-EOS.strip
|
||||
[
|
||||
[0] #<User:0x01234567
|
||||
@_start_transaction_state = {},
|
||||
@aggregation_cache = {},
|
||||
@attributes_cache = {},
|
||||
@column_types = {
|
||||
"admin" => #<ActiveRecord::ConnectionAdapters::SQLite3Column:0x01234567
|
||||
attr_accessor :coder = nil,
|
||||
attr_accessor :primary = false,
|
||||
attr_reader :default = nil,
|
||||
attr_reader :default_function = nil,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :name = "admin",
|
||||
attr_reader :null = true,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil,
|
||||
attr_reader :sql_type = "boolean",
|
||||
attr_reader :type = :boolean
|
||||
>,
|
||||
"created_at" => #<ActiveRecord::ConnectionAdapters::SQLite3Column:0x01234567
|
||||
attr_accessor :coder = nil,
|
||||
attr_accessor :primary = false,
|
||||
attr_reader :default = nil,
|
||||
attr_reader :default_function = nil,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :name = "created_at",
|
||||
attr_reader :null = true,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil,
|
||||
attr_reader :sql_type = "datetime",
|
||||
attr_reader :type = :datetime
|
||||
>,
|
||||
"id" => #<ActiveRecord::ConnectionAdapters::SQLite3Column:0x01234567
|
||||
attr_accessor :coder = nil,
|
||||
attr_accessor :primary = true,
|
||||
attr_reader :default = nil,
|
||||
attr_reader :default_function = nil,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :name = "id",
|
||||
attr_reader :null = false,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil,
|
||||
attr_reader :sql_type = "INTEGER",
|
||||
attr_reader :type = :integer
|
||||
>,
|
||||
"name" => #<ActiveRecord::ConnectionAdapters::SQLite3Column:0x01234567
|
||||
attr_accessor :coder = nil,
|
||||
attr_accessor :primary = false,
|
||||
attr_reader :default = nil,
|
||||
attr_reader :default_function = nil,
|
||||
attr_reader :limit = 255,
|
||||
attr_reader :name = "name",
|
||||
attr_reader :null = true,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil,
|
||||
attr_reader :sql_type = "varchar(255)",
|
||||
attr_reader :type = :string
|
||||
>,
|
||||
"rank" => #<ActiveRecord::ConnectionAdapters::SQLite3Column:0x01234567
|
||||
attr_accessor :coder = nil,
|
||||
attr_accessor :primary = false,
|
||||
attr_reader :default = nil,
|
||||
attr_reader :default_function = nil,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :name = "rank",
|
||||
attr_reader :null = true,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil,
|
||||
attr_reader :sql_type = "integer",
|
||||
attr_reader :type = :integer
|
||||
>
|
||||
},
|
||||
@column_types_override = nil,
|
||||
@destroyed = false,
|
||||
@marked_for_destruction = false,
|
||||
@new_record = true,
|
||||
@previously_changed = {},
|
||||
@readonly = false,
|
||||
@reflects_state = [
|
||||
[0] false
|
||||
],
|
||||
@transaction_state = nil,
|
||||
@txn = nil,
|
||||
attr_accessor :attributes = {
|
||||
"admin" => false,
|
||||
"created_at" => "1992-10-10 12:30:00",
|
||||
"id" => nil,
|
||||
"name" => "Diana",
|
||||
"rank" => 1
|
||||
},
|
||||
attr_accessor :destroyed_by_association = nil,
|
||||
attr_reader :association_cache = {},
|
||||
attr_reader :changed_attributes = {
|
||||
"admin" => nil,
|
||||
"created_at" => nil,
|
||||
"name" => nil,
|
||||
"rank" => nil
|
||||
}
|
||||
>,
|
||||
[1] #<User:0x01234567
|
||||
@_start_transaction_state = {},
|
||||
@aggregation_cache = {},
|
||||
@attributes_cache = {},
|
||||
@column_types = {
|
||||
"admin" => #<ActiveRecord::ConnectionAdapters::SQLite3Column:0x01234567
|
||||
attr_accessor :coder = nil,
|
||||
attr_accessor :primary = false,
|
||||
attr_reader :default = nil,
|
||||
attr_reader :default_function = nil,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :name = "admin",
|
||||
attr_reader :null = true,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil,
|
||||
attr_reader :sql_type = "boolean",
|
||||
attr_reader :type = :boolean
|
||||
>,
|
||||
"created_at" => #<ActiveRecord::ConnectionAdapters::SQLite3Column:0x01234567
|
||||
attr_accessor :coder = nil,
|
||||
attr_accessor :primary = false,
|
||||
attr_reader :default = nil,
|
||||
attr_reader :default_function = nil,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :name = "created_at",
|
||||
attr_reader :null = true,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil,
|
||||
attr_reader :sql_type = "datetime",
|
||||
attr_reader :type = :datetime
|
||||
>,
|
||||
"id" => #<ActiveRecord::ConnectionAdapters::SQLite3Column:0x01234567
|
||||
attr_accessor :coder = nil,
|
||||
attr_accessor :primary = true,
|
||||
attr_reader :default = nil,
|
||||
attr_reader :default_function = nil,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :name = "id",
|
||||
attr_reader :null = false,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil,
|
||||
attr_reader :sql_type = "INTEGER",
|
||||
attr_reader :type = :integer
|
||||
>,
|
||||
"name" => #<ActiveRecord::ConnectionAdapters::SQLite3Column:0x01234567
|
||||
attr_accessor :coder = nil,
|
||||
attr_accessor :primary = false,
|
||||
attr_reader :default = nil,
|
||||
attr_reader :default_function = nil,
|
||||
attr_reader :limit = 255,
|
||||
attr_reader :name = "name",
|
||||
attr_reader :null = true,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil,
|
||||
attr_reader :sql_type = "varchar(255)",
|
||||
attr_reader :type = :string
|
||||
>,
|
||||
"rank" => #<ActiveRecord::ConnectionAdapters::SQLite3Column:0x01234567
|
||||
attr_accessor :coder = nil,
|
||||
attr_accessor :primary = false,
|
||||
attr_reader :default = nil,
|
||||
attr_reader :default_function = nil,
|
||||
attr_reader :limit = nil,
|
||||
attr_reader :name = "rank",
|
||||
attr_reader :null = true,
|
||||
attr_reader :precision = nil,
|
||||
attr_reader :scale = nil,
|
||||
attr_reader :sql_type = "integer",
|
||||
attr_reader :type = :integer
|
||||
>
|
||||
},
|
||||
@column_types_override = nil,
|
||||
@destroyed = false,
|
||||
@marked_for_destruction = false,
|
||||
@new_record = true,
|
||||
@previously_changed = {},
|
||||
@readonly = false,
|
||||
@reflects_state = [
|
||||
[0] false
|
||||
],
|
||||
@transaction_state = nil,
|
||||
@txn = nil,
|
||||
attr_accessor :attributes = {
|
||||
"admin" => true,
|
||||
"created_at" => "2003-05-26 14:15:00",
|
||||
"id" => nil,
|
||||
"name" => "Laura",
|
||||
"rank" => 2
|
||||
},
|
||||
attr_accessor :destroyed_by_association = nil,
|
||||
attr_reader :association_cache = {},
|
||||
attr_reader :changed_attributes = {
|
||||
"admin" => nil,
|
||||
"created_at" => nil,
|
||||
"name" => nil,
|
||||
"rank" => nil
|
||||
}
|
||||
>
|
||||
]
|
||||
EOS
|
||||
elsif activerecord_3_2?
|
||||
str = <<-EOS.strip
|
||||
[
|
||||
[0] #<User:0x01234567
|
||||
|
@ -474,10 +1103,10 @@ EOS
|
|||
@attributes_cache = {},
|
||||
@destroyed = false,
|
||||
@marked_for_destruction = false,
|
||||
@mass_assignment_options = nil,
|
||||
@new_record = true,
|
||||
@previously_changed = {},
|
||||
@readonly = false,
|
||||
@relation = nil,
|
||||
attr_accessor :attributes = {
|
||||
"admin" => false,
|
||||
"created_at" => "1992-10-10 12:30:00",
|
||||
|
@ -491,18 +1120,17 @@ EOS
|
|||
"created_at" => nil,
|
||||
"name" => nil,
|
||||
"rank" => nil
|
||||
},
|
||||
attr_reader :mass_assignment_options = nil
|
||||
}
|
||||
>,
|
||||
[1] #<User:0x01234567
|
||||
@aggregation_cache = {},
|
||||
@attributes_cache = {},
|
||||
@destroyed = false,
|
||||
@marked_for_destruction = false,
|
||||
@mass_assignment_options = nil,
|
||||
@new_record = true,
|
||||
@previously_changed = {},
|
||||
@readonly = false,
|
||||
@relation = nil,
|
||||
attr_accessor :attributes = {
|
||||
"admin" => true,
|
||||
"created_at" => "2003-05-26 14:15:00",
|
||||
|
@ -516,93 +1144,6 @@ EOS
|
|||
"created_at" => nil,
|
||||
"name" => nil,
|
||||
"rank" => nil
|
||||
},
|
||||
attr_reader :mass_assignment_options = nil
|
||||
>
|
||||
]
|
||||
EOS
|
||||
# ActiveRecord 3.0.x
|
||||
#--------------------------------------------------------------------------
|
||||
elsif ActiveRecord::VERSION::STRING.start_with?('3.0')
|
||||
str = <<-EOS.strip
|
||||
[
|
||||
[0] #<User:0x01234567
|
||||
@attributes_cache = {},
|
||||
@destroyed = false,
|
||||
@marked_for_destruction = false,
|
||||
@new_record = true,
|
||||
@previously_changed = {},
|
||||
@readonly = false,
|
||||
attr_accessor :attributes = {
|
||||
"admin" => false,
|
||||
"created_at" => "?",
|
||||
"name" => "Diana",
|
||||
"rank" => 1
|
||||
},
|
||||
attr_reader :changed_attributes = {
|
||||
"admin" => nil,
|
||||
"created_at" => nil,
|
||||
"name" => nil,
|
||||
"rank" => nil
|
||||
}
|
||||
>,
|
||||
[1] #<User:0x01234567
|
||||
@attributes_cache = {},
|
||||
@destroyed = false,
|
||||
@marked_for_destruction = false,
|
||||
@new_record = true,
|
||||
@previously_changed = {},
|
||||
@readonly = false,
|
||||
attr_accessor :attributes = {
|
||||
"admin" => true,
|
||||
"created_at" => "?",
|
||||
"name" => "Laura",
|
||||
"rank" => 2
|
||||
},
|
||||
attr_reader :changed_attributes = {
|
||||
"admin" => nil,
|
||||
"created_at" => nil,
|
||||
"name" => nil,
|
||||
"rank" => nil
|
||||
}
|
||||
>
|
||||
]
|
||||
EOS
|
||||
# ActiveRecord 2.0.x
|
||||
#--------------------------------------------------------------------------
|
||||
elsif ActiveRecord::VERSION::STRING.start_with?('2.')
|
||||
str = <<-EOS.strip
|
||||
[
|
||||
[0] #<User:0x01234567
|
||||
@attributes_cache = {},
|
||||
@changed_attributes = {
|
||||
"admin" => nil,
|
||||
"created_at" => nil,
|
||||
"name" => nil,
|
||||
"rank" => nil
|
||||
},
|
||||
@new_record = true,
|
||||
attr_accessor :attributes = {
|
||||
"admin" => false,
|
||||
"created_at" => "1992-10-10 12:30:00",
|
||||
"name" => "Diana",
|
||||
"rank" => 1
|
||||
}
|
||||
>,
|
||||
[1] #<User:0x01234567
|
||||
@attributes_cache = {},
|
||||
@changed_attributes = {
|
||||
"admin" => nil,
|
||||
"created_at" => nil,
|
||||
"name" => nil,
|
||||
"rank" => nil
|
||||
},
|
||||
@new_record = true,
|
||||
attr_accessor :attributes = {
|
||||
"admin" => true,
|
||||
"created_at" => "2003-05-26 14:15:00",
|
||||
"name" => "Laura",
|
||||
"rank" => 2
|
||||
}
|
||||
>
|
||||
]
|
||||
|
@ -672,11 +1213,7 @@ EOS
|
|||
|
||||
# spec 2
|
||||
out = @ap.send(:awesome, User.methods.grep(/primary_key/))
|
||||
if activerecord_version >= "4.1"
|
||||
expect(out).to match(/\sprimary_key\(.*?\)\s+Class \(ActiveRecord::AttributeMethods::PrimaryKey::ClassMethods\)/)
|
||||
else
|
||||
expect(out).to match(/\sprimary_key\(.*?\)\s+User/)
|
||||
end
|
||||
expect(out).to match(/\sprimary_key\(.*?\)\s+Class \(ActiveRecord::AttributeMethods::PrimaryKey::ClassMethods\)/)
|
||||
|
||||
# spec 3
|
||||
out = @ap.send(:awesome, User.methods.grep(/validate/))
|
||||
|
|
|
@ -18,6 +18,10 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
|
|||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
||||
require 'awesome_print'
|
||||
|
||||
Dir[File.dirname(__FILE__) + '/support/**/*.rb'].each do |file|
|
||||
require file
|
||||
end
|
||||
|
||||
def stub_dotfile!
|
||||
dotfile = File.join(ENV["HOME"], ".aprc")
|
||||
expect(File).to receive(:readable?).at_least(:once).with(dotfile).and_return(false)
|
||||
|
|
26
spec/support/active_record_versions.rb
Normal file
26
spec/support/active_record_versions.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
module ActiveRecordVersions
|
||||
def activerecord_version
|
||||
Gem::Version.new(ActiveRecord::VERSION::STRING)
|
||||
end
|
||||
|
||||
def activerecord_4_2?
|
||||
Gem::Requirement.new('~> 4.2.0').satisfied_by?(activerecord_version)
|
||||
end
|
||||
|
||||
def activerecord_4_1?
|
||||
Gem::Requirement.new('~> 4.1.0').satisfied_by?(activerecord_version)
|
||||
end
|
||||
|
||||
def activerecord_4_0?
|
||||
Gem::Requirement.new('~> 4.0.0').satisfied_by?(activerecord_version)
|
||||
end
|
||||
|
||||
def activerecord_3_2?
|
||||
Gem::Requirement.new('~> 3.2.0').satisfied_by?(activerecord_version)
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.include(ActiveRecordVersions)
|
||||
config.extend(ActiveRecordVersions)
|
||||
end
|
Loading…
Reference in a new issue