views:

38

answers:

1

Am using 'devise' gem for authentication and rspec for testing. My problem is after spec execution the test data is not getting cleared from DB, because of this subsequent execution of specs fail. Following is the spec:

describe User do

it "should return a valid user when valid email and password are used" do user = User.new(:email => '[email protected]', :password => 'test123', :password_confirmation => 'test123') user.save user.should be_valid end

end

Is there anything more that i am excepted to do here?

A: 

I'm not sure myself. I'm learning how to make gems and I ran across this issue. I added the method in spec_helper:


def purge_db
  [User, Subscription, Dorkus].each {|c| c.delete_all}
end

Spec::Runner.configure do |config|
  config.before(:each) { purge_db }
end         
Ramon Tayag