'rails tutorial Test errors that occur after Chapter 6

I'm a beginner. rails tutorial I got an error like this when I did a rails test after finishing Chapter 6 and before giving it to git. I did an integration test with rails test. However, it does not become Green but becomes Red.

# Running:

E

Error:
StaticPagesControllerTest#test_should_get_help:
ActiveRecord::StatementInvalid: SQLite3::BusyException: database is locked


Error:
StaticPagesControllerTest#test_should_get_help:
NoMethodError: undefined method `each' for nil:NilClass



rails test test/controllers/static_pages_controller_test.rb:10

E

Error:
StaticPagesControllerTest#test_should_get_about:
RuntimeError: database is locked


Error:
StaticPagesControllerTest#test_should_get_about:
NoMethodError: undefined method `each' for nil:NilClass



rails test test/controllers/static_pages_controller_test.rb:16

E

Error:
StaticPagesControllerTest#test_should_get_contact:
RuntimeError: database is locked


Error:
StaticPagesControllerTest#test_should_get_contact:
NoMethodError: undefined method `each' for nil:NilClass



rails test test/controllers/static_pages_controller_test.rb:22

E

Error:
StaticPagesControllerTest#test_should_get_home:
ActiveRecord::StatementInvalid: SQLite3::BusyException: database is locked


Error:
StaticPagesControllerTest#test_should_get_home:
NoMethodError: undefined method `each' for nil:NilClass



rails test test/controllers/static_pages_controller_test.rb:4

E

Error:
ApplicationHelperTest#test_full_title_helper:
RuntimeError: database is locked


Error:
ApplicationHelperTest#test_full_title_helper:
NoMethodError: undefined method `each' for nil:NilClass



rails test test/helpers/application_helper_test.rb:4

.....E

Error:
UserTest#test_name_should_be_present:
ActiveRecord::StatementInvalid: SQLite3::BusyException: database is locked
    test/models/user_test.rb:13:in `block in <class:UserTest>'


rails test test/models/user_test.rb:11

.....

Write the file written in the error.

require 'test_helper'

class StaticPagesControllerTest < ActionDispatch::IntegrationTest
  test "should get home" do
    get root_path
    assert_response :success
    assert_select "title", "Ruby on Rails Tutorial Sample App"
  end

  test "should get help" do
    get help_path
    assert_response :success
    assert_select "title", "Help | Ruby on Rails Tutorial Sample App"
  end

  test "should get about" do
    get about_path
    assert_response :success
    assert_select "title", "About | Ruby on Rails Tutorial Sample App"
  end

  test "should get contact" do
    get contact_path
    assert_response :success
    assert_select "title", "Contact | Ruby on Rails Tutorial Sample App"
  end

end

require 'test_helper'

class ApplicationHelperTest < ActionView::TestCase
    test "full title helper" do
        assert_equal full_title, "Ruby on Rails Tutorial Sample App"
        assert_equal full_title("Help"), "Help | Ruby on Rails Tutorial Sample App"
    end
  
end

require 'test_helper'

class UserTest < ActiveSupport::TestCase
  def setup
    @user = User.new(name: "Example User", email: "[email protected]",
      password: "foobar", password_confirmation: "foobar")
  end
  test "should be valid" do
    assert @user.valid?
  end
  
  test "name should be present" do
    @user.name = ""
    assert_not @user.valid?
  end
  test "email should be present" do
    @user.email = ""
    assert_not @user.valid?
  end
  test "name should not be too long" do
    @user.name = "a" * 51
    assert_not @user.valid?
  end

  test "email should not be too long" do
    @user.email = "a" * 244 + "@example.com"
    assert_not @user.valid?
  end
  test "email validation should accept valid addresses" do
    valid_addresses = %w[[email protected] [email protected] [email protected]
                         [email protected] [email protected]]
    valid_addresses.each do |valid_address|
      @user.email = valid_address
      assert @user.valid?, "#{valid_address.inspect} should be valid"
    end
  end
  test "email addresses should be unique" do
    duplicate_user = @user.dup
    @user.save
    assert_not duplicate_user.valid?
  end
  test "password should be present (nonblank)" do
    @user.password = @user.password_confirmation = " " * 6
    assert_not @user.valid?
  end

  test "password should have a minimum length" do
    @user.password = @user.password_confirmation = "a" * 5
    assert_not @user.valid?
  end
end
default: &default
  adapter: sqlite3
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 20 } %>
  timeout: 20000

development:
  <<: *default
  database: db/development.sqlite3

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  <<: *default
  database: db/test.sqlite3

production:
  <<: *default
  database: db/production.sqlite3

What I tried


SQLite3::BusyException: database is locked:のエラーの解決 I tried the above but it didn't work. Is there any good solution?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source