hiroaki514 / contents_management_app

0 stars 0 forks source link

【RspecとCapybaraのローカル環境での実行とテストの記述練習】 #215

Open hiroaki514 opened 11 months ago

hiroaki514 commented 11 months ago

<gemファイルについて>

  gem 'rspec-rails', '6.0.2'

  gem 'capybara', '3.39.0'
  gem 'selenium-webdriver', '4.9.0'

上記が既に入っている状態

hiroaki514 commented 11 months ago
$ winpty docker compose run app bundle exec rspec spec/system/user_content_upload_spec.rb

[+] Building 0.0s (0/0)                                       docker:default
[+] Creating 2/0
 ✔ Container ecs_metadata_service  Running                              0.0s
 ✔ Container mysql_host            Running                              0.0s
[+] Building 0.0s (0/0)                                       docker:default
Error response from daemon: Address already in use

Rspecも既に導入されている状態のようで、テストファイルも少数ですが発見できました。 実行を試みたところポートの問題が出ているようです。

yoshichiba commented 11 months ago

これできそうですね! winpty使えばいけるのかな🤔

hiroaki514 commented 11 months ago

<2023/11の現状>

1. "docker compose down"でアプリケーションのDBを落とす

  1. "winpty docker compose run app bundle exec rails db:migrate:reset "テスト側のDBにマイグレーションファイルが読み込まれていなければ実行
  2. "winpty docker compose run app bundle exec rspec spec/models/corp_admin_action_log_spec.rb "でテスト実行
hiroaki514 commented 11 months ago

12/06 フォルダの名前に全角が入っているため解決する

1.bundle install 2.bundle exec rspec spec/models/corp_admin_action_log_spec.rb

hiroaki514 commented 10 months ago

@yoshichiba

・フォルダの名前問題を解消しました! ・bundle installが実行できるようになりました

【問題点】 ・以下のエラーが発生しています。

$ bundle install
Fetching gem metadata from https://rubygems.org/.......
Resolving dependencies...
Fetching aws-partitions 1.866.0
Fetching google-apis-drive_v3 0.46.0
Installing aws-partitions 1.866.0
Installing mysql2 0.5.4 with native extensions
Installing google-apis-drive_v3 0.46.0
Installing libv8 8.4.255.0.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/libv8-8.4.255.0.1/ext/libv8
C:/Ruby30-x64/bin/ruby.exe extconf.rb --with-system-v8
creating Makefile
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/libv8-8.4.255.0.1/ext/libv8/builder.rb:57:in
`setup_python!': libv8 requires python 2 to be installed in order to build, but
it is currently not available (RuntimeError)
from
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/libv8-8.4.255.0.1/ext/libv8/builder.rb:39:in
`build_libv8!'
from
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/libv8-8.4.255.0.1/ext/libv8/location.rb:24:in
`install!'
        from extconf.rb:7:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/libv8-8.4.255.0.1 for inspection.
Results logged to
C:/Ruby30-x64/lib/ruby/gems/3.0.0/extensions/x64-mingw32/3.0.0/libv8-8.4.255.0.1/gem_make.out

  C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:120:in `run'
C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/ext/ext_conf_builder.rb:28:in
`build'
C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:188:in
`build_extension'
C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:222:in `block
in build_extensions'
  C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:219:in `each'
C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:219:in
`build_extensions'
C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/installer.rb:839:in
`build_extensions'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/rubygems_gem_installer.rb:76:in
`build_extensions'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/rubygems_gem_installer.rb:28:in
`install'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/source/rubygems.rb:203:in
`install'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/installer/gem_installer.rb:54:in
`install'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/installer/parallel_installer.rb:130:in
`do_install'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/installer/parallel_installer.rb:121:in
`block in worker_pool'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/worker.rb:62:in
`apply_func'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/worker.rb:57:in
`block in process_queue'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/worker.rb:54:in
`loop'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/worker.rb:54:in
`process_queue'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/worker.rb:90:in
`block (2 levels) in create_threads'

An error occurred while installing libv8 (8.4.255.0.1), and Bundler cannot
continue.

In Gemfile:
  mini_racer was resolved to 0.2.15, which depends on
    libv8
mpg-yoshiharu-chiba commented 10 months ago

mini_racerというGemでこけてるのでこちらは削除してしまって問題ないです!

In Gemfile:
  mini_racer was resolved to 0.2.15, which depends on
    libv8
mpg-yoshiharu-chiba commented 10 months ago

あ、削除ではなくコメントアウトでお願いしますmm

hiroaki514 commented 10 months ago

@yoshichiba

コメントアウト後に再度実行してみたところmysql2の箇所でエラーが発生しました。 また、pythonが足りていない?というエラーも出ているでしょうか。

$ bundle install
Fetching gem metadata from https://rubygems.org/.......
Resolving dependencies...
Installing mysql2 0.5.4 with native extensions
Installing curb 0.9.10 with native extensions
Installing libv8 7.3.492.27.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/libv8-7.3.492.27.1/ext/libv8
C:/Ruby30-x64/bin/ruby.exe extconf.rb --with-system-v8
creating Makefile
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/libv8-7.3.492.27.1/ext/libv8/builder.rb:57:in
`setup_python!': libv8 requires python 2 to be installed in order to build, but
it is currently not available (RuntimeError)
from
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/libv8-7.3.492.27.1/ext/libv8/builder.rb:39:in
`build_libv8!'
from
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/libv8-7.3.492.27.1/ext/libv8/location.rb:24:in
`install!'
        from extconf.rb:7:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/libv8-7.3.492.27.1 for inspection.
Results logged to
C:/Ruby30-x64/lib/ruby/gems/3.0.0/extensions/x64-mingw32/3.0.0/libv8-7.3.492.27.1/gem_make.out

  C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:120:in `run'
C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/ext/ext_conf_builder.rb:28:in
`build'
C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:188:in
`build_extension'
C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:222:in `block
in build_extensions'
  C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:219:in `each'
C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:219:in
`build_extensions'
C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/installer.rb:839:in
`build_extensions'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/rubygems_gem_installer.rb:76:in
`build_extensions'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/rubygems_gem_installer.rb:28:in
`install'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/source/rubygems.rb:203:in
`install'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/installer/gem_installer.rb:54:in
`install'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/installer/parallel_installer.rb:130:in
`do_install'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/installer/parallel_installer.rb:121:in
`block in worker_pool'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/worker.rb:62:in
`apply_func'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/worker.rb:57:in
`block in process_queue'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/worker.rb:54:in
`loop'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/worker.rb:54:in
`process_queue'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/worker.rb:90:in
`block (2 levels) in create_threads'

An error occurred while installing libv8 (7.3.492.27.1), and Bundler cannot
continue.

In Gemfile:
  libv8

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/mysql2-0.5.4/ext/mysql2
C:/Ruby30-x64/bin/ruby.exe extconf.rb
--with-ldflags\=-L/usr/local/opt/openssl@1.0/lib
--with-cppflags\=-I/usr/local/opt/openssl@1.0/include
--with-mysql-config\=/usr/local/Cellar/mysql@5.6/5.6.47/bin/mysql_config
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_enc_interned_str() in ruby.h... yes
-----
Cannot find mysql_config at /usr/local/Cellar/mysql@5.6/5.6.47/bin/mysql_config
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/Ruby30-x64/bin/$(RUBY_BASE_NAME)
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib
        --without-mysql-lib=${mysql-dir}/lib
        --with-mysql-config

To see why this extension failed to compile, please check the mkmf.log which can
be found here:

C:/Ruby30-x64/lib/ruby/gems/3.0.0/extensions/x64-mingw32/3.0.0/mysql2-0.5.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/mysql2-0.5.4 for inspection.
Results logged to
C:/Ruby30-x64/lib/ruby/gems/3.0.0/extensions/x64-mingw32/3.0.0/mysql2-0.5.4/gem_make.out

  C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:120:in `run'
C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/ext/ext_conf_builder.rb:28:in
`build'
C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:188:in
`build_extension'
C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:222:in `block
in build_extensions'
  C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:219:in `each'
C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/ext/builder.rb:219:in
`build_extensions'
C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/rubygems/installer.rb:839:in
`build_extensions'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/rubygems_gem_installer.rb:76:in
`build_extensions'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/rubygems_gem_installer.rb:28:in
`install'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/source/rubygems.rb:203:in
`install'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/installer/gem_installer.rb:54:in
`install'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/installer/parallel_installer.rb:130:in
`do_install'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/installer/parallel_installer.rb:121:in
`block in worker_pool'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/worker.rb:62:in
`apply_func'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/worker.rb:57:in
`block in process_queue'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/worker.rb:54:in
`loop'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/worker.rb:54:in
`process_queue'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.4.22/lib/bundler/worker.rb:90:in
`block (2 levels) in create_threads'

An error occurred while installing mysql2 (0.5.4), and Bundler cannot continue.

In Gemfile:
  mysql2