engine/spec/support/be_valid.rb

32 lines
633 B
Ruby
Raw Normal View History

2010-04-09 09:23:41 +00:00
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"
2010-04-09 09:23:41 +00:00
end
def description
"be valid"
end
end
def be_valid
BeValid.new
end
end
end
end