Reputation: 16222
I must be missing something super simple here. In the rspec code below, the second assertion is failing, the one where the code should have been set to 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
Here is the model code:
require 'sequel'
class LotteryCode < Sequel::Model
many_to_one :campus
def redeem!
is_redeemed = true
save
end
end
What am I doing wrong?
Upvotes: 0
Views: 96
Reputation: 12139
You want self.is_redeemed = true
, your current code just creates a local variable.
Upvotes: 2