Class: RiotRails::ActiveRecord::DoesNotAllowValuesForMacro
- Inherits:
-
AssertionMacro
- Object
- Riot::AssertionMacro
- AssertionMacro
- RiotRails::ActiveRecord::DoesNotAllowValuesForMacro
- Defined in:
- lib/riot/active_record/assertion_macros.rb
Overview
An ActiveRecord assertion that expects to fail with a given value or set of values for a given attribute.
context "a User" do
setup { User.new }
topic.does_not_allow_values_for :email, "a"
topic.does_not_allow_values_for :email, "a@b", "e [email protected]"
end
Instance Method Summary collapse
Methods inherited from AssertionMacro
Instance Method Details
#evaluate(actual, attribute, *values) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/riot/active_record/assertion_macros.rb', line 62 def evaluate(actual, attribute, *values) good_values = [] values.each do |value| good_values << value unless error_from_writing_value(actual, attribute, value) end failure_msg = "expected %s not to allow value(s) %s" good_values.empty? ? pass : fail(failure_msg % [attribute.inspect, good_values.inspect]) end |