module RSpec::BeValidWhenMatcher
Container module for be_valid_when
matcher definition and implementation.
Public Instance Methods
be_valid_when(*args)
click to toggle source
Model validity assertion.
@overload be_valid_when
(field)
@param field (Symbol) field name to use.
@overload be_valid_when
(field, value)
@param field (Symbol) field name to use. @param value (Any) field `value` to use in matching.
@overload be_valid_when
(field, value, message)
@param field (Symbol) field name to use. @param value (Any) field `value` to use in matching. @param message [String] a `message` used for failure message.
@raise [ArgumentError] if field name is not a symbol. @raise [ArgumentError] if invoked with more than three parameters. @return [self]
# File lib/rspec/be_valid_when_matcher.rb, line 201 def be_valid_when(*args) number_of_arguments = args.size field_name = args.shift if number_of_arguments == 1 BeValidWhen.new(field_name) else BeValidWhen.new(field_name).is(*args) end end