Class: RiotRails::ActiveRecord::ValidatesPresenceOfMacro

Inherits:
AssertionMacro
  • Object
show all
Defined in:
lib/riot/active_record/assertion_macros.rb

Overview

An ActiveRecord assertion that expects to fail when a given attribute is validated after a nil value is provided to it.

context "a User" do
  setup { User.new }
  topic.validates_presence_of(:name)
end

Instance Method Summary collapse

Methods inherited from AssertionMacro

#error_from_writing_value

Instance Method Details

#evaluate(actual, attribute) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/riot/active_record/assertion_macros.rb', line 22

def evaluate(actual, attribute)
  if error_from_writing_value(actual, attribute, nil)
    pass("validates presence of #{attribute.inspect}")
  else
    fail("expected to validate presence of #{attribute.inspect}")
  end
end