Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9011023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:37:07+00:00 2026-06-16T02:37:07+00:00

I recently switched a very simple rails app from rspec to minitest. I also

  • 0

I recently switched a very simple rails app from rspec to minitest. I also use capybara and factory_girl.

I have 3 separate integration test files, all of which involve logging the user in using something along the lines of:

before(:each) do
  user = Factory(:user)
  visit login_path
  fill_in "Email", :with => user.email
  fill_in "Password", :with => user.password
  click_button "Log in"
end

After I switched to minitest, it seems as if the sessions ceased to tear down after each test. For instance, I would test login using the above code in a test file named “users_integration_test.rb” and when it begins running another test file, say “sessions_integration_test.rb”, the user is already logged in before I can log in again using the above code.

My question is: Is this an intentional difference between rspec and minitest, and I simply need to logout the user after each test? Or did I make a mistake setting up minitest?

I am using the same minitest_helper file as in the Minitest Railscast.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:37:09+00:00Added an answer on June 16, 2026 at 2:37 am

    I got it to tear down correctly with this. Hope it helps!
    Mr. Maeshima’s answer may very well work too. I have not tried.

    ENV["RAILS_ENV"] = "test"
    require File.expand_path("../../config/environment", __FILE__)
    require "minitest/autorun"
    require "capybara/rails"
    require "active_support/testing/setup_and_teardown"
    
    Dir[Rails.root.join("test/support/**/*.rb")].each {|f| require f}
    
    DatabaseCleaner.strategy = :truncation
    
    class IntegrationTest < MiniTest::Spec
      include Rails.application.routes.url_helpers
      include Capybara::DSL
      register_spec_type(/integration$/, self)
      Capybara.javascript_driver = :selenium
    
      after do
        DatabaseCleaner.clean       # Truncate the database
        Capybara.reset_sessions!    # Forget the (simulated) browser state
        Capybara.use_default_driver # Revert Capybara.current_driver to Capybara.default_driver
      end
    end
    
    class HelperTest < MiniTest::Spec
      include ActiveSupport::Testing::SetupAndTeardown
      include ActionView::TestCase::Behavior
      register_spec_type(/Helper$/, self)
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently switched from XML to PHP for use with my simple AJAX program.
I have a Rails (version 3.2.1) project and I recently switched from Ruby 1.8.7
I recently switched from eclipse and netbeans to intellij, but I have also liferay
I've recently switched my app over to Rails 3.1 and began using the asset
I recently switched over from SVN to Hg. I used to use TortoiseSVN, and
I recently switched to postgres for a rails app in development since I deployed
I recently switched my rails database over from sqlite3 to mysql, and since doing
I recently switched jobs and therefore also switched from oracle to sql server. I'm
I recently switched from Eclipse to Intellij. Now I'm trying to use the andengine
I recently switched from MySQL to PostgreSQL in my Django app and I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.