Class: SerializationScopes::Shoulda::Matchers::SerializeMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/serialization_scopes/matchers/serialize_matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#failure_messageObject (readonly)

Returns the value of attribute failure_message.



41
42
43
# File 'lib/serialization_scopes/matchers/serialize_matcher.rb', line 41

def failure_message
  @failure_message
end

#negative_failure_messageObject (readonly)

Returns the value of attribute negative_failure_message.



41
42
43
# File 'lib/serialization_scopes/matchers/serialize_matcher.rb', line 41

def negative_failure_message
  @negative_failure_message
end

Instance Method Details

#descriptionObject



43
44
45
46
47
48
49
# File 'lib/serialization_scopes/matchers/serialize_matcher.rb', line 43

def description
  result = "serialize"
  result << " with #{@scope.inspect} scope" unless @scope.nil?
  result << " to #{@to.inspect}" unless @to.nil?
  result << " with #{@count} attributes" unless @count.nil?
  result
end

#for(scope) ⇒ Object



20
21
22
23
# File 'lib/serialization_scopes/matchers/serialize_matcher.rb', line 20

def for(scope)
  @scope = scope
  self
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
38
39
# File 'lib/serialization_scopes/matchers/serialize_matcher.rb', line 35

def matches?(subject)
  @subject = subject
  @subject.id ||= rand(10000000)
  correct_root? && correct_column_count?
end

#to(value) ⇒ Object



25
26
27
28
# File 'lib/serialization_scopes/matchers/serialize_matcher.rb', line 25

def to(value)
  @to = value
  self
end

#with_attributes(count) ⇒ Object



30
31
32
33
# File 'lib/serialization_scopes/matchers/serialize_matcher.rb', line 30

def with_attributes(count)
  @count = count
  self
end