0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

RubyMineでRspecのテストの自動実行を設定してみた

Posted at

背景

RubyMineを利用しているので、設定について試してみました。

環境

❯ sw_vers
ProductName:	macOS
ProductVersion:	12.3.1
BuildVersion:	21E258
RubyMine 2023.2.1

設定

  • Edit Configurationsをクリックし、設定を追加
    image.png
  • Rspecの設定を新たに追加
    • NameとSpecs folderを指定
      image.png
  • 実行したところ、以下のエラーが表示された
/bin/zsh -c "bash -c 'env RBENV_VERSION=3.0.2 /usr/local/Cellar/rbenv/1.2.0/libexec/rbenv exec ruby /Users/feng.zhang/rfs/vendor/bundle/ruby/3.0.0/bin/rspec /Users/feng.zhang/rfs/spec --require teamcity/spec/runner/formatter/teamcity/formatter --format '\"'\"'Spec::Runner::Formatter::TeamcityFormatter'\"'\"' --pattern '\"'\"'**/*_spec.rb'\"'\"''"
Testing started at 16:42 ...
/Users/feng.zhang/.rbenv/versions/3.0.2/lib/ruby/3.0.0/rubygems.rb:281:in `find_spec_for_exe': can't find gem rspec-core (>= 0.a) with executable rspec (Gem::GemNotFoundException)
	from /Users/feng.zhang/.rbenv/versions/3.0.2/lib/ruby/3.0.0/rubygems.rb:300:in `activate_bin_path'
	from /Users/feng.zhang/rfs/vendor/bundle/ruby/3.0.0/bin/rspec:23:in `<main>'

Process finished with exit code 1
  • specが見つからないため、設定を行う
    • ./bin/rspecを指定
      image.png
  • さらに別のエラーが発生
/bin/zsh -c "bash -c 'env RBENV_VERSION=3.0.2 /usr/local/Cellar/rbenv/1.2.0/libexec/rbenv exec ruby /Users/feng.zhang/rfs/bin/rspec /Users/feng.zhang/rfs/spec --require teamcity/spec/runner/formatter/teamcity/formatter --format '\"'\"'Spec::Runner::Formatter::TeamcityFormatter'\"'\"' --pattern '\"'\"'**/*_spec.rb'\"'\"''"
Testing started at 21:50 ...
Warning: the running version of Bundler (2.2.22) is older than the version that created the lockfile (2.4.12). We suggest you to upgrade to the version that created the lockfile by running `gem install bundler:2.4.12`.
/Users/feng.zhang/rfs/vendor/bundle/ruby/3.0.0/gems/spring-4.0.0/lib/spring/client/run.rb:76:in `spawn': No such file or directory - spring (Errno::ENOENT)
	from /Users/feng.zhang/rfs/vendor/bundle/ruby/3.0.0/gems/spring-4.0.0/lib/spring/client/run.rb:76:in `boot_server'
	from /Users/feng.zhang/rfs/vendor/bundle/ruby/3.0.0/gems/spring-4.0.0/lib/spring/client/run.rb:56:in `cold_run'
	from /Users/feng.zhang/rfs/vendor/bundle/ruby/3.0.0/gems/spring-4.0.0/lib/spring/client/run.rb:33:in `rescue in call'
	from /Users/feng.zhang/rfs/vendor/bundle/ruby/3.0.0/gems/spring-4.0.0/lib/spring/client/run.rb:30:in `call'
	from /Users/feng.zhang/rfs/vendor/bundle/ruby/3.0.0/gems/spring-4.0.0/lib/spring/client/command.rb:7:in `call'
	from /Users/feng.zhang/rfs/vendor/bundle/ruby/3.0.0/gems/spring-4.0.0/lib/spring/client.rb:30:in `run'
	from /Users/feng.zhang/rfs/vendor/bundle/ruby/3.0.0/gems/spring-4.0.0/bin/spring:49:in `<top (required)>'
	from /Users/feng.zhang/rfs/vendor/bundle/ruby/3.0.0/gems/spring-4.0.0/lib/spring/binstub.rb:11:in `load'
	from /Users/feng.zhang/rfs/vendor/bundle/ruby/3.0.0/gems/spring-4.0.0/lib/spring/binstub.rb:11:in `<top (required)>'
	from <internal:/Users/feng.zhang/.rbenv/versions/3.0.2/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/Users/feng.zhang/.rbenv/versions/3.0.2/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /Users/feng.zhang/rfs/bin/spring:12:in `block in <top (required)>'
	from <internal:kernel>:90:in `tap'
	from /Users/feng.zhang/rfs/bin/spring:9:in `<top (required)>'
	from /Users/feng.zhang/rfs/bin/rspec:4:in `load'
	from /Users/feng.zhang/rfs/bin/rspec:4:in `<main>'
/Users/feng.zhang/rfs/vendor/bundle/ruby/3.0.0/gems/spring-4.0.0/lib/spring/client/run.rb:26:in `initialize': No such file or directory - connect(2) for /private/var/folders/xr/yldgyptn0s72bcrmnwxpf_kh0000gp/T/rmcbab4a02rfs/4150fadaa77507282be06c8a87a8828f (Errno::ENOENT)
	from /Users/feng.zhang/rfs/vendor/bundle/ruby/3.0.0/gems/spring-4.0.0/lib/spring/client/run.rb:26:in `open'
	from /Users/feng.zhang/rfs/vendor/bundle/ruby/3.0.0/gems/spring-4.0.0/lib/spring/client/run.rb:26:in `connect'
	from /Users/feng.zhang/rfs/vendor/bundle/ruby/3.0.0/gems/spring-4.0.0/lib/spring/client/run.rb:31:in `call'
	from /Users/feng.zhang/rfs/vendor/bundle/ruby/3.0.0/gems/spring-4.0.0/lib/spring/client/command.rb:7:in `call'
	from /Users/feng.zhang/rfs/vendor/bundle/ruby/3.0.0/gems/spring-4.0.0/lib/spring/client.rb:30:in `run'
	from /Users/feng.zhang/rfs/vendor/bundle/ruby/3.0.0/gems/spring-4.0.0/bin/spring:49:in `<top (required)>'
	from /Users/feng.zhang/rfs/vendor/bundle/ruby/3.0.0/gems/spring-4.0.0/lib/spring/binstub.rb:11:in `load'
	from /Users/feng.zhang/rfs/vendor/bundle/ruby/3.0.0/gems/spring-4.0.0/lib/spring/binstub.rb:11:in `<top (required)>'
	from <internal:/Users/feng.zhang/.rbenv/versions/3.0.2/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/Users/feng.zhang/.rbenv/versions/3.0.2/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /Users/feng.zhang/rfs/bin/spring:12:in `block in <top (required)>'
	from <internal:kernel>:90:in `tap'
	from /Users/feng.zhang/rfs/bin/spring:9:in `<top (required)>'
	from /Users/feng.zhang/rfs/bin/rspec:4:in `load'
	from /Users/feng.zhang/rfs/bin/rspec:4:in `<main>'

Process finished with exit code 1
  • springも指定する

image.png

  • それでもエラーが発生
/bin/zsh -c "bash -c 'env RBENV_VERSION=3.0.2 /usr/local/Cellar/rbenv/1.2.0/libexec/rbenv exec ruby /Users/feng.zhang/rfs/vendor/bundle/ruby/3.0.0/bin/spring rspec /Users/feng.zhang/rfs/spec --require teamcity/spec/runner/formatter/teamcity/formatter --format '\"'\"'Spec::Runner::Formatter::TeamcityFormatter'\"'\"' --pattern '\"'\"'**/*_spec.rb'\"'\"''"
Testing started at 21:53 ...
/Users/feng.zhang/.rbenv/versions/3.0.2/lib/ruby/3.0.0/rubygems.rb:281:in `find_spec_for_exe': can't find gem spring (>= 0.a) with executable spring (Gem::GemNotFoundException)
	from /Users/feng.zhang/.rbenv/versions/3.0.2/lib/ruby/3.0.0/rubygems.rb:300:in `activate_bin_path'
	from /Users/feng.zhang/rfs/vendor/bundle/ruby/3.0.0/bin/spring:23:in `<main>'

Process finished with exit code 1
  • bundleの設定が誤っている可能性が考えられる
❯ bundle --version
Bundler version 2.3.10

❯ tail -n 3 Gemfile.lock

BUNDLED WITH
   2.4.12
  • bundleのバージョンを揃える
❯ gem uninstall bundler
Gem bundler-2.2.22 cannot be uninstalled because it is a default gem
Successfully uninstalled bundler-2.3.10

~
❯ gem list | grep bundler
bundler (default: 2.2.22)

❯ gem install bundler:2.4.12
Fetching bundler-2.4.12.gem
Successfully installed bundler-2.4.12
Parsing documentation for bundler-2.4.12
Installing ri documentation for bundler-2.4.12
Done installing documentation for bundler after 0 seconds
1 gem installed
  • 再度テストを実行すると、正常に動作した

image.png

その他

  • auto test deplyの設定

image.png

  • auto testを有効にする

image.png

参照

image.png

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?