I need to test a callback that's run before_validation
, but as I want to test only the callback I don't want test to fail when validation fails, and at the moment I get:
ActiveRecord::RecordInvalid:
Validation failed: Preview Invalid video ID
I've tried out a lot of stuff. I believe that my callback method is not called when using .save(:validate => false)
because it runs on before_validation
.
But when I do something like this:
show = FactoryGirl.build :show
show.should_receive :parse_url
show.save
I get
Failure/Error: show.should_receive :parse_url
(#<Show:0x007fd9954699e0>).parse_url(any args)
expected: 1 time
received: 0 times
despite my code in the model:
before_validation :parse_url, :on => :save
Also beside the method call I want to check the fields after they were formatted.
I'll be very thankful for any help.