LoginSignup
1
1

More than 3 years have passed since last update.

【備忘録】Rails6でのRSpecがうまく起動しない時

Last updated at Posted at 2019-09-15

対象者

他の記事を見れば大体解決できるけど、それでも解決できなかった人向け

エラー内容

エラー内容
     Failure/Error: fill_in 'session_email', with: 'a@example.com'

     Capybara::ElementNotFound:
       Unable to find field "session_email" that is not disabled

fill_in のあとはラベルの名前もidも試したりしたけどどうしても解決できない。

原因

Rails6にUpdateする時、./config/application.rbにconfig.hosts << "hostname"を指定してたことが原因
昔,Herokuにあげるとき、Blocked Hostのエラーがでたため、application.rbにhostを指定したため。
ホストを指定する時は,./enviroment/development.rbや./enviroment/production.rbに追加する。
application.rbには追加しない
参考 : Blocked Host

解決策

config.hosts << "hostname"を削除
ここではわかりやすくするためコメントアウト

./config/application.rb
     require_relative 'boot'

require 'csv'
require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module Myapp
  class Application < Rails::Application
    # Initialize configuration defaults for originally generated Rails version.
    config.load_defaults 5.2
    #config.hosts << "hostname"
    config.time_zone = 'Asia/Tokyo'

    config.generators do |g|
      g.test_framework = "rspec"
      g.helper_specs = false
      g.view_specs = false
    end

    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration can go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded after loading
    # the framework and any gems in your application.
  end
end

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1