Topic: RSpec raise_error problem?

Hey guys,

I'm running edge Rails and edge RSpec, so this might be caused by that. Or by my stupidity really, either way. But essentially, I'm trying to say that a call to an ActiveRecord object should raise_error(), but it's not working, and the test continuously fails, but with the error message that I'm trying to catch. Am I catching this wrong? Is it some problem in RSpec?

models/user.rb
class User < ActiveRecord::Base
  def select_gift(gift)
    if gift.event.attendees.include?(self)
    ...
  else
    raise
  end
end

spec/models/user_spec.rb
require File.dirname(__FILE__) + '/../spec_helper'

describe User, "as a recipient" do
  before(:each) do
    @user = User.create
    @event = Event.create
    @gift = Gift.create
    @user.hosting_event = @event
  end

  it "should not be able to select gifts for my event" do
    @user.hosting_event.gifts << @gift
    @user.select_gift(@gift).should raise_error
  end


@user is not a member of attendees, so it should raise an error. And it does. But somehow the error flunks the test, rather than verifying it with .should raise_error.

Does anyone know what I'm doing wrong?

Re: RSpec raise_error problem?

Nevermind, I figured it out. You have to enclose the raising entity in lambda {}.