engine/spec/support/be_valid.rb
2010-04-09 11:23:41 +02:00

31 lines
633 B
Ruby

module Spec
module Rails
module Matchers
class BeValid #:nodoc:
def matches?(model)
@model = model
@model.errors.clear
@model.errors.empty? && @model.valid?
end
def failure_message
"#{@model.class} expected to be valid but had errors:\n #{@model.errors.full_messages.join("\n ")}"
end
def negative_failure_message
"#{@model.class} expected to be invalid but was valid.\n"
end
def description
"be valid"
end
end
def be_valid
BeValid.new
end
end
end
end