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 => ‘[email protected]’,
: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 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