class Mongoid::Matchers::AcceptNestedAttributesForMatcher

Public Class Methods

new(attribute) click to toggle source
# File lib/matchers/accept_nested_attributes.rb, line 16
def initialize(attribute)
  @attribute = attribute.to_s
  @options = {}
end

Public Instance Methods

description() click to toggle source
# File lib/matchers/accept_nested_attributes.rb, line 36
def description
  description = "accepts_nested_attributes_for :#{@attribute}"
end
failure_message() click to toggle source
# File lib/matchers/accept_nested_attributes.rb, line 26
def failure_message
  "Expected #{expectation} (#{@problem})"
end
failure_message_when_negated()
matches?(subject) click to toggle source
# File lib/matchers/accept_nested_attributes.rb, line 21
def matches?(subject)
  @subject = subject
  match?
end
negative_failure_message() click to toggle source
# File lib/matchers/accept_nested_attributes.rb, line 30
def negative_failure_message
  "Did not expect #{expectation}"
end
Also aliased as: failure_message_when_negated

Protected Instance Methods

config() click to toggle source
# File lib/matchers/accept_nested_attributes.rb, line 54
def config
  model_class.nested_attributes["#{@attribute}_attributes"]
end
exists?() click to toggle source
# File lib/matchers/accept_nested_attributes.rb, line 45
def exists?
  if config
    true
  else
    @problem = 'is not declared'
    false
  end
end
expectation() click to toggle source
# File lib/matchers/accept_nested_attributes.rb, line 62
def expectation
  "#{model_class.name} to accept nested attributes for #{@attribute}"
end
match?() click to toggle source
# File lib/matchers/accept_nested_attributes.rb, line 41
def match?
  exists?
end
model_class() click to toggle source
# File lib/matchers/accept_nested_attributes.rb, line 58
def model_class
  @subject.class
end