Guest User

Untitled

a guest
May 26th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")
  2.  
  3. class ValidationTest
  4. include ActiveModel::Validations
  5.  
  6. before_validate :do_something
  7. validates_presence_of :something
  8.  
  9. def do_something
  10. raise "callback"
  11. end
  12.  
  13. def something
  14. raise "validation"
  15. end
  16. end
  17.  
  18. class ValidationTest2
  19. include ActiveModel::Validations
  20.  
  21. validates_presence_of :something
  22. before_validate :do_something
  23.  
  24. def do_something
  25. raise "callback"
  26. end
  27.  
  28. def something
  29. raise "validation"
  30. end
  31. end
  32.  
  33. describe ValidationTest do
  34. it "should run the validations properly" do
  35. p = ValidationTest.new
  36. lambda { p.valid? }.should raise_error("callback")
  37. end
  38. end
  39.  
  40. describe ValidationTest2 do
  41. it "should run the validations properly" do
  42. p = ValidationTest2.new
  43. lambda { p.valid? }.should raise_error("callback")
  44. end
  45. end
Add Comment
Please, Sign In to add comment