質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Capybara

Capybaraは、 Rubyで開発されているWebアプリケーションテストフレームワークです。Webブラウザ不要でブラウザ上のユーザー操作及びJavaScriptの挙動を自動化することができます。

Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

WSL(Windows Subsystem for Linux)

WSL (Windows Subsystem for Linux) は、Windows10のOS上でLinux向けのバイナリプログラムを実行可能にする機能です。また、WindowsOSのAPIを用いた仕組みを提供しており、Linux側からWindowsOSへのファイルアクセスもできます。

RSpec

RSpecはRuby用のBDD(behaviour-driven development)フレームワークです。

Ubuntu

Ubuntuは、Debian GNU/Linuxを基盤としたフリーのオペレーティングシステムです。

Q&A

解決済

3回答

2427閲覧

Rails WSL2(Ubuntu)でのRSpec実行エラー

fukahire

総合スコア0

Capybara

Capybaraは、 Rubyで開発されているWebアプリケーションテストフレームワークです。Webブラウザ不要でブラウザ上のユーザー操作及びJavaScriptの挙動を自動化することができます。

Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

WSL(Windows Subsystem for Linux)

WSL (Windows Subsystem for Linux) は、Windows10のOS上でLinux向けのバイナリプログラムを実行可能にする機能です。また、WindowsOSのAPIを用いた仕組みを提供しており、Linux側からWindowsOSへのファイルアクセスもできます。

RSpec

RSpecはRuby用のBDD(behaviour-driven development)フレームワークです。

Ubuntu

Ubuntuは、Debian GNU/Linuxを基盤としたフリーのオペレーティングシステムです。

0グッド

1クリップ

投稿2020/06/01 10:55

前提・実現したいこと

「現場で使えるRuby on Rails5 速習実践ガイド」で学習しており、
5章でRSpecのsystem spec実行でエラーが発生しました。

エラーが発生したコマンド
「bundle exec rspec spec/system/tasks_spec.rb」

発生している問題・エラーメッセージ

Capybara starting Puma... * Version 3.12.6 , codename: Llamas in Pajamas * Min threads: 0, max threads: 4 * Listening on tcp://127.0.0.1:42299 F Failures: 1) タスク管理機能 一覧表示機能 ユーザAがログインしているとき ユーザAが作成したタスクが表示される Got 0 failures and 2 other errors: 1.1) Failure/Error: visit login_path NotImplementedError: fork() function is unimplemented on this machine # ./spec/system/tasks_spec.rb:15:in `block (4 levels) in <top (required)>' 1.2) Failure/Error: @pid = Kernel.fork { # Children of the forked process will inherit its process group # This is to make sure that all grandchildren dies when this Process instance is killed ::Process.setpgid 0, 0 if leader? if @cwd Dir.chdir(@cwd) end exec_r.close NotImplementedError: fork() function is unimplemented on this machine

該当のソースコード

Ruby

1Gemfile2source 'https://rubygems.org' 3git_source(:github) { |repo| "https://github.com/#{repo}.git" } 4 5ruby '2.5.1' 6 7# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 8gem 'rails', '~> 5.2.4', '>= 5.2.4.3' 9# Use postgresql as the database for Active Record 10gem 'pg', '>= 0.18', '< 2.0' 11# Use Puma as the app server 12gem 'puma', '~> 3.11' 13# Use SCSS for stylesheets 14gem 'sass-rails', '~> 5.0' 15# Use Uglifier as compressor for JavaScript assets 16gem 'uglifier', '>= 1.3.0' 17# See https://github.com/rails/execjs#readme for more supported runtimes 18# gem 'mini_racer', platforms: :ruby 19 20# Use CoffeeScript for .coffee assets and views 21gem 'coffee-rails', '~> 4.2' 22# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 23gem 'turbolinks', '~> 5' 24# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 25gem 'jbuilder', '~> 2.5' 26# Use Redis adapter to run Action Cable in production 27# gem 'redis', '~> 4.0' 28# Use ActiveModel has_secure_password 29gem 'bcrypt', '~> 3.1.7' 3043 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 31gem 'rails_autolink' 32 33# Use ActiveStorage variant 34# gem 'mini_magick', '~> 4.8' 35 36# Use Capistrano for deployment 37# gem 'capistrano-rails', group: :development 38 39# Reduces boot times through caching; required in config/boot.rb 40gem 'bootsnap', '>= 1.1.0', require: false 41 42group :development, :test do 43 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 44 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 45 gem 'rspec-rails', '~> 3.7' 46 gem 'factory_bot_rails', '~> 4.11' 47end 48 49group :development do 50 # Access an interactive console on exception pages or by calling 'console' anywhere in the code. 51 gem 'web-console', '>= 3.3.0' 52 gem 'listen', '>= 3.0.5', '< 3.2' 53end 54 55group :test do 56 # Adds support for Capybara system testing and selenium driver 57 gem 'capybara'#, '>= 2.15' 58 gem 'selenium-webdriver' 59 # Easy installation and use of chromedriver to run system tests with Chrome 60 #gem 'chromedriver-helper' 61 gem 'webdrivers' 62 #gem 'webdrivers', '~> 4.0' 63end 64 65# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 66gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 67 68gem 'slim-rails' 69gem 'html2slim' 70 71gem 'bootstrap'

Ruby

1「spec_helper.rb」 2require 'capybara/rspec' 3 4#Selenium::WebDriver::Chrome.driver_path = "/mnt/c/Program Files/chromedriver_win32/chromedriver.exe" 5 6RSpec.configure do |config| 7 config.before(:each, type: :system) do 8 driven_by :selenium_chrome_headless 9 end 10 11 config.expect_with :rspec do |expectations| 12 expectations.include_chain_clauses_in_custom_matcher_descriptions = true 13 end 14 15 config.mock_with :rspec do |mocks| 16 mocks.verify_partial_doubles = true 17 end 18 19 config.shared_context_metadata_behavior = :apply_to_host_groups 20 21end

Ruby

1「tasks_spec.rb」 2require 'rails_helper' 3 4describe 'タスク管理機能', type: :system do 5 describe '一覧表示機能' do 6 before do 7 # ユーザAを作成しておく 8 user_a = FactoryBot.create(:user, name: 'ユーザA', email: 'a@example.com') 9 # 作成者がユーザAであるタスクを作成しておく 10 FactoryBot.create(:task, name: '最初のタスク', user: user_a) 11 end 12 13 context 'ユーザAがログインしているとき' do 14 before do 15 # ユーザAでログインする 16 visit login_path 17 #fill_in 'メールアドレス', with: 'a@example.com' 18 #fill_in 'パスワード', with: 'password' 19 #click_button 'ログインする' 20 end 21 22 it 'ユーザAが作成したタスクが表示される' do 23 # 作成済みのタスクの名称が画面上に表示されていることを確認 24 #expect(page).to have_content '最初のタスク' 25 end 26 end 27 end 28end 29

試したこと

下記メッセージで検索してみましたが、めぼしい情報が見つかりませんでした。
「NotImplementedError:fork() function is unimplemented on this machine」

下記URLの対策を実施。エラーは解消されませんでした。
WSL Ubuntu 上で chromedriver を使った System Spec を動かす

また、WSL2からWSL1に戻して実行してみましたが、変化ありませんでした。

補足情報(FW/ツールのバージョンなど)

ホストOS:Windows 10 64bit
仮想環境:WSL2
ゲストOS:Ubuntu 20.04 LTS
Ruby:Ruby2.5.1
Rails:Rails5.2.4.3

以上、解決方法や参考になりそうな情報等、ご存じの方がいらっしゃいましたらご教示お願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答3

0

自己解決

根本的に解決はできていませんが、Ubuntu 18.04で下記のURLの対策を実施したところrspecを実行できました。
WSL Ubuntu 上で chromedriver を使った System Spec を動かす

投稿2020/07/09 13:16

fukahire

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

私も全く同じエラーが出ました。私だけでは無かったんですね。未だに解決出来ずに学習がストップしています。。

投稿2020/06/14 03:47

sho_watanabe

総合スコア4

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

私も全く同じエラーが出ました。私だけでは無かったんですね。未だに解決出来ずに学習がストップしていますので、どなたか分かる方、教えていただきたいです。。

投稿2020/06/14 03:46

sho_watanabe

総合スコア4

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問