Object
@private
# File lib/shoulda/matchers/active_record/serialize_matcher.rb, line 99 def as(type) @options[:type] = type self end
# File lib/shoulda/matchers/active_record/serialize_matcher.rb, line 104 def as_instance_of(type) @options[:instance_type] = type self end
# File lib/shoulda/matchers/active_record/serialize_matcher.rb, line 124 def description description = "serialize :#{@name}" description += " class_name => #{@options[:type]}" if @options.key?(:type) description end
# File lib/shoulda/matchers/active_record/serialize_matcher.rb, line 114 def failure_message "Expected #{expectation} (#{@missing})" end
# File lib/shoulda/matchers/active_record/serialize_matcher.rb, line 119 def failure_message_when_negated "Did not expect #{expectation}" end
# File lib/shoulda/matchers/active_record/serialize_matcher.rb, line 141 def class_valid? if @options[:type] klass = model_class.serialized_attributes[@name] if klass == @options[:type] true else if klass.respond_to?(:object_class) && klass.object_class == @options[:type] true else @missing = ":#{@name} should be a type of #{@options[:type]}" false end end else true end end
# File lib/shoulda/matchers/active_record/serialize_matcher.rb, line 180 def expectation expectation = "#{model_class.name} to serialize the attribute called :#{@name}" expectation += " with a type of #{@options[:type]}" if @options[:type] expectation += " with an instance of #{@options[:instance_type]}" if @options[:instance_type] expectation end
# File lib/shoulda/matchers/active_record/serialize_matcher.rb, line 163 def instance_class_valid? if @options.key?(:instance_type) if model_class.serialized_attributes[@name].class == @options[:instance_type] true else @missing = ":#{@name} should be an instance of #{@options[:type]}" false end else true end end
# File lib/shoulda/matchers/active_record/serialize_matcher.rb, line 159 def model_class @subject.class end
Generated with the Darkfish Rdoc Generator 2.