「現場で使える Ruby on Rails 5速習実践ガイド」の第5章Rspecの実行で躓きます。
うまく実行されなかったためネットで情報を集めていると、同じような方がいたので、
色んなサイトを参考にし、結果的に、以下のサイトのBにて対応しましたが、うまくいかず、続いてAを試しましたが、エラーは一向に変わりませんでした。
環境:WSL,ubuntu上, OS: windows10
参考にしたところ:
[https://gist.github.com/upinetree/fb71a947cc100e7918b7b280485d620c](現場で使える Ruby on Rails 5速習実践ガイド)
エラーが
Failure/Error: visit login_path Selenium::WebDriver::Error::UnknownError: unknown error: Chrome failed to start: crashed (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
と表示されました。
関連ありそうな情報として、
google-chrome -v Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Permission denied Trace/breakpoint trap (core dumped) google-chrome -version Google Chrome 77.0.3865.90
その他、rspecを実行すると以下のようなコメントが冒頭にでるのも気になります。
(bundle updateはしています)
2019-10-06 22:36:43 WARN Selenium [DEPRECATION] Selenium::WebDriver::Chrome#driver_path= is deprecated. Use Selenium::WebDriver::Chrome::Service#driver_path= instead.
spec/spec_helper.rb の記述は以下です
spec/spec_helper.rb
1require 'capybara/rspec' 2require 'selenium-webdriver' 3Selenium::WebDriver::Chrome.driver_path = '/mnt/c/Windows/chromedriver.exe' 4 5RSpec.configure do |config| 6 config.before(:each, type: :system) do 7 driven_by :selenium_chrome_headless 8 end 9 # rspec-expectations config goes here. You can use an alternate 10 # assertion/expectation library such as wrong or the stdlib/minitest 11 # assertions if you prefer. 12 config.expect_with :rspec do |expectations| 13 # This option will default to `true` in RSpec 4. It makes the `description` 14 # and `failure_message` of custom matchers include text for helper methods 15 # defined using `chain`, e.g.: 16 # be_bigger_than(2).and_smaller_than(4).description 17 # # => "be bigger than 2 and smaller than 4" 18 # ...rather than: 19 # # => "be bigger than 2" 20 expectations.include_chain_clauses_in_custom_matcher_descriptions = true 21 end 22 23 # rspec-mocks config goes here. You can use an alternate test double 24 # library (such as bogus or mocha) by changing the `mock_with` option here. 25 config.mock_with :rspec do |mocks| 26 # Prevents you from mocking or stubbing a method that does not exist on 27 # a real object. This is generally recommended, and will default to 28 # `true` in RSpec 4. 29 mocks.verify_partial_doubles = true 30 end 31 32 # This option will default to `:apply_to_host_groups` in RSpec 4 (and will 33 # have no way to turn it off -- the option exists only for backwards 34 # compatibility in RSpec 3). It causes shared context metadata to be 35 # inherited by the metadata hash of host groups and examples, rather than 36 # triggering implicit auto-inclusion in groups with matching metadata. 37 config.shared_context_metadata_behavior = :apply_to_host_groups 38 39# The settings below are suggested to provide a good initial experience 40# with RSpec, but feel free to customize to your heart's content. 41=begin 42 # This allows you to limit a spec run to individual examples or groups 43 # you care about by tagging them with `:focus` metadata. When nothing 44 # is tagged with `:focus`, all examples get run. RSpec also provides 45 # aliases for `it`, `describe`, and `context` that include `:focus` 46 # metadata: `fit`, `fdescribe` and `fcontext`, respectively. 47 config.filter_run_when_matching :focus 48 49 # Allows RSpec to persist some state between runs in order to support 50 # the `--only-failures` and `--next-failure` CLI options. We recommend 51 # you configure your source control system to ignore this file. 52 config.example_status_persistence_file_path = "spec/examples.txt" 53 54 # Limits the available syntax to the non-monkey patched syntax that is 55 # recommended. For more details, see: 56 # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ 57 # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ 58 # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode 59 config.disable_monkey_patching! 60 61 # Many RSpec users commonly either run the entire suite or an individual 62 # file, and it's useful to allow more verbose output when running an 63 # individual spec file. 64 if config.files_to_run.one? 65 # Use the documentation formatter for detailed output, 66 # unless a formatter has already been configured 67 # (e.g. via a command-line flag). 68 config.default_formatter = "doc" 69 end 70 71 # Print the 10 slowest examples and example groups at the 72 # end of the spec run, to help surface which specs are running 73 # particularly slow. 74 config.profile_examples = 10 75 76 # Run specs in random order to surface order dependencies. If you find an 77 # order dependency and want to debug it, you can fix the order by providing 78 # the seed, which is printed after each run. 79 # --seed 1234 80 config.order = :random 81 82 # Seed global randomization in this process using the `--seed` CLI option. 83 # Setting this allows you to use `--seed` to deterministically reproduce 84 # test failures related to randomization by passing the same `--seed` value 85 # as the one that triggered the failure. 86 Kernel.srand config.seed 87=end 88end
そのほか、関係ありそうな以下のコードも実行したのですが、ダメでした。
sudo apt-get install chromium-browser
chromedriverをデスクトップに解凍して、移動させたのですが、これもダメでした。
sudo mv /mnt/c/Users/user/Desktop/chromedriver_win32/chromedriver.exe /bin/chromedriver.exe
どうしたらうまくいくか分からないので、どなたかアドバイスをいただけたら幸いです。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。