Class: RiotRails::ActiveRecord::AllowsValuesForMacro
- Inherits:
-
AssertionMacro
- Object
- Riot::AssertionMacro
- AssertionMacro
- RiotRails::ActiveRecord::AllowsValuesForMacro
- Defined in:
- lib/riot/active_record/assertion_macros.rb
Overview
An ActiveRecord assertion that expects to pass with a given value or set of values for a given attribute.
context "a User" do
setup { User.new }
topic.allows_values_for :email, "[email protected]"
topic.allows_values_for :email, "[email protected]", "[email protected]"
end
Instance Method Summary collapse
Methods inherited from AssertionMacro
Instance Method Details
#evaluate(actual, attribute, *values) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/riot/active_record/assertion_macros.rb', line 42 def evaluate(actual, attribute, *values) bad_values = [] values.each do |value| bad_values << value if error_from_writing_value(actual, attribute, value) end failure_msg = "expected %s to allow value(s) %s" bad_values.empty? ? pass : fail(failure_msg % [attribute.inspect, bad_values.inspect]) end |