ruby on rails - How to change Factory girl boolean attribute inside the test -
here factory:
factory :acceptance favor user accepted false end and here request spec:
describe "to acceptances" let (:favor) { create(:favor, user: user) } let (:acceptance) { create(:acceptance, user: user, favor: favor)} context "when has accepted acceptance" "shold not allow sending more acceptances" acceptance.accepted = true expect(permission.allow?(:acceptances, :create, favor)).to false end the problem acceptance.accepted = true. figured out, not setting accepted attribute true. how can achive this?
thanks lot time!
you need save record, otherwise you've changed local copy of acceptance. add acceptance.save or update_attribute save you.
describe "to acceptances" let (:favor) { create(:favor, user: user) } let (:acceptance) { create(:acceptance, user: user, favor: favor)} context "when has accepted acceptance" "shold not allow sending more acceptances" acceptance.update_attribute(:accepted, true) expect(permission.allow?(:acceptances, :create, favor)).to false end end end
Comments
Post a Comment