Question

I've inherited a bunch of old (v2) Shoulda tests. The documentation on what was deprecated between v2 to v3 is quite limited, and I can't seem to find the recommended way to rewrite the "assert_bad_value" line below:

context "Content page validations" do
  setup do
    @page = Factory.build(:content_page)
  end

  should "require a unique page id" do
    Factory(:content_page, :page_id => 'PAGE_ID')
    assert_bad_value(@page, :page_id, 'page_id', /already been taken/)
  end
end

Any help would be greatly appreciated!

Was it helpful?

Solution

Looks like should_not allow_value may be a solution:

E.G. should_not allow_value("", "blah").for(:email)

https://github.com/thoughtbot/shoulda

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top