Rspec / shoulda: testing, that a custom validator is called

后端 未结 2 1783
陌清茗
陌清茗 2021-01-21 11:23

I have a custom validator (located in app/validators/uri_validator.rb) which is used in:

validates :link, uri: true

How do I specify this in my

2条回答
  •  暖寄归人
    2021-01-21 12:25

    Another option is to use the allow_value matcher, although not ideal it can work in some circumstances.

    it { should allow_value(value_which_is_valid).for(:link) }
    it { should_not allow_value(value_which_is_invalid).for(:link) }
    

提交回复
热议问题