Fix failing tests on rails 3.1 and higher
This commit is contained in:
parent
d9906d84ce
commit
3b891cf704
|
@ -65,19 +65,34 @@ module Shoulda # :nodoc:
|
||||||
end
|
end
|
||||||
|
|
||||||
def class_valid?
|
def class_valid?
|
||||||
if @type
|
if(!@type)
|
||||||
model_class.serialized_attributes[@name] == @type
|
return true
|
||||||
else
|
end
|
||||||
|
|
||||||
|
klass = model_class.serialized_attributes[@name]
|
||||||
|
|
||||||
|
if klass == @type
|
||||||
true
|
true
|
||||||
|
else
|
||||||
|
if klass.respond_to?(:object_class) && klass.object_class == @type
|
||||||
|
true
|
||||||
|
else
|
||||||
|
@missing = ":#{@name} should be a type of #{@type}"
|
||||||
|
false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def instance_class_valid?
|
def instance_class_valid?
|
||||||
if @instance_type
|
if !@instance_type
|
||||||
klass = model_class.serialized_attributes[@name].class
|
return true
|
||||||
klass == @instance_type
|
end
|
||||||
else
|
|
||||||
|
if model_class.serialized_attributes[@name].class == @instance_type
|
||||||
true
|
true
|
||||||
|
else
|
||||||
|
@missing = ":#{@name} should be an instance of #{@type}"
|
||||||
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -88,6 +103,7 @@ module Shoulda # :nodoc:
|
||||||
def expectation
|
def expectation
|
||||||
expectation = "#{model_class.name} to serialize the attribute called :#{@name}"
|
expectation = "#{model_class.name} to serialize the attribute called :#{@name}"
|
||||||
expectation += " with a type of #{@type}" if @type
|
expectation += " with a type of #{@type}" if @type
|
||||||
|
expectation += " with an instance of #{@instance_type}" if @instance_type
|
||||||
expectation
|
expectation
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue