[rspec-users] Change in isolation behaviour 1.08 - 1.10 ?

Jeroen Houben jeroen.houben at lostboys.nl
Mon Dec 17 08:13:05 EST 2007


I just moved from 1.08 to 1.10 and now have one example failing, which,
under 1.08, passed. Is the due to a change in behaviour?

Here's my spec (removed some passing examples)

require File.dirname(__FILE__) + '/../spec_helper'

describe "A user" do

  before(:each) do
    @user = User.new
    @valid_user = User.new(
      :email    => 'bert.valid at lostboys.nl',
      :fname    => 'bert',
      :lname    => 'valid',
      :jobtitle => "programmer"

  it "should have a unique email address" do
    @valid_user.save.should == true
    @user.email = @valid_user.email
    @user.should have(1).error_on(:email)
  it "should allow two users with the same name" do
    @valid_user.save.should == true
    @user.fname = @valid_user.fname
    @user.lname = @valid_user.lname
    @user.should have(:no).error_on(:fname)
    @user.should have(:no).error_on(:lname)

The second example now fails, as the inserted record from the first example
is not rolled back.

I can just put a User.delete_all in an after(:each) block but I think it
would be nicer if Rspec wrapped each example in a db transaction. Wasn't
this they way things worked in 1.08 ?


More information about the rspec-users mailing list