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

aslak hellesoy aslak.hellesoy at gmail.com
Mon Dec 17 09:47:23 EST 2007


On Dec 17, 2007 2:13 PM, Jeroen Houben <jeroen.houben at lostboys.nl> wrote:
> Hi,
>
> 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"
>     )
>   end
>
>   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)
>   end
>
>   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)
>   end
>
> end
>
> The second example now fails, as the inserted record from the first example
> is not rolled back.
>

I don't see a fixtures :users in your spec. Do you have this in your
spec_helper?
Have you rerun script/generate rspec after you upgraded? There are
some changes in the spec_helper.rb file between the two releases.

Aslak

> 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 ?
>
> Jeroen
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list