0

I have a rails model with a

validate :existing_invoice, on: :create

directive. I would like to skip this callback in rspec. In another question (Skip callbacks on Factory Girl and Rspec), I read to use

skip_callback(:validate, :create, :after, :existing_invoice)

as solution, but it looks like this doesn't work. (gives an error "undefined local variable or method `after'") How should I implement my skip_callback to do the job?

Community
  • 1
  • 1
Danny
  • 5,945
  • 4
  • 32
  • 52
  • See Stackoverflow Question: http://stackoverflow.com/questions/19449019/rails-4-skip-callback#answer-19449936 – Allerin Jan 23 '14 at 06:15
  • @Abdul - thanks for "refreshing" this question! I understand they're modifying the callback with an if condition, which however I consider bad practice if you're only doing this because of testing... – Danny Jan 23 '14 at 06:35
  • thanks for your reply. I am not in favour of modifying callback using condition. Basically I was talking about http://www.allerin.com/blog/save-an-object-skipping-callbacks-in-rails-3-application/ – Allerin Jan 23 '14 at 07:21

0 Answers0