我一定在这里遗漏了一些超级简单的东西。在下面的 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
我究竟做错了什么?