0
我必須在這裏錯過一些超級簡單的東西。在下面的RSpec的代碼,第二斷言失敗,在其中執行代碼應該已經被設置爲true:續集:爲什麼不保存保存方法?
describe "#redeem!" do
it "marks a code as redeemed" do
existing_code = LotteryCode[promo_code: "A5"]
existing_code.is_redeemed.should == false
existing_code.redeem!
changed_code = LotteryCode[promo_code: "A5"]
changed_code.is_redeemed.should == true
end
end
下面是型號代碼:
require 'sequel'
class LotteryCode < Sequel::Model
many_to_one :campus
def redeem!
is_redeemed = true
save
end
end
什麼時我做錯了?