初心者です。
rails tutorial 6章まで終えてgitにあげる前にrails testを行ったらこのようなエラーが出ました。
error
# 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 .....
エラーに書いてあるファイル書きます。
static_pages_controller_test.rb
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
application_helper_test.rb
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
user_test.rb
require 'test_helper' class UserTest < ActiveSupport::TestCase def setup @user = User.new(name: "Example User", email: "user@example.com", 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[user@example.com USER@foo.COM A_US-ER@foo.bar.org first.last@foo.jp alice+bob@baz.cn] 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
user.yml
database.yml
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
試したこと
SQLite3::BusyException: database is locked:のエラーの解決を試しましたがダメでした。
何かいい解決策はあるでしょうか?
まだ回答がついていません
会員登録して回答してみよう