Forum: Ruby on Rails Test not Reseting

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Chris W. (Guest)
on 2006-05-04 02:10
My test are not resetting for each method in the test class.

It was promised to me on page 146 of Agile Web D. on Rails that
it would.

Am I doing something wrong?  The "@delete_victim = User.find(4)" bust
the setup class each time it comes around, even though that is in my
users.yml

class UserTest < Test::Unit::TestCase
  fixtures :users

  def setup
    @chris_logged_in    = User.new({:username => 'cwinslett', :password
=> 'testpassword'})
    @chris_logged_in    = @chris_logged_in.try_to_login
    @sherri             = User.find(2)
    @delete_victim      = User.find(4)
  end

  # Replace this with your real tests.

  def test_truth
    assert_kind_of User, @chris_logged_in
    assert_kind_of User, @sherri
    assert_kind_of User, @investor
  end

  def test_destroy
    @delete_victim.destroy
    assert_raise(ActiveRecord::RecordNotFound){User.find(@delete_victim.id)}
  end

  def test_create_user
    @tom_lawyer            = User.new
    @tom_lawyer.username   = "tlawyer"
    @tom_lawyer.password   = "i<3lawyers"
    @tom_lawyer.email      = "removed_email_address@domain.invalid"
    @tom_lawyer.first_name = "Tom"
    @tom_lawyer.last_name  = "Lawyer"
    assert @tom_lawyer.save, @tom_lawyer.errors.full_messages.join("; ")
    @tom_lawyer            = User.new({:username => "tlawyer", :password
=> "i<3lawyers"})
    @tom_lawyer            = @tom_lawyer.try_to_login
    assert_equal "a6e29adca96aac7c85275792c7562e85",
@tom_lawyer.hashed_password
  end
end
Jakob S. (Guest)
on 2006-05-05 16:11
(Received via mailing list)
Chris W. wrote:
> My test are not resetting for each method in the test class.

You're probably running a DB without transaction support, let me
guess... MySQL on MyISAM tables?

Either move to a DB/table-engine that supports transactions or turn off
transaction-based testing in test/test_helper.rb.
This topic is locked and can not be replied to.