Runnin rspec by IntelliJ

I use my specifications inside IntelliJ. I removed my gems and reinstalled them by installing the package (due to another error), and now I get an error when trying to run the specifications.

I noticed that using specs from intelliJ uses:

from /home/user/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' 

which fails when starting from the shell (I placed the print inside the kernel_require script).

I also see that the ruby ​​version from intelliJ:

 "ruby 2.2.4: 230" 

and from the shell:

 ruby -e 'print "ruby #{ RUBY_VERSION }p#{ RUBY_PATCHLEVEL }"' ruby 2.2.6p396% 

Mistake:

  /home/user/.rvm/rubies/ruby-2.2.4/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /home/user/.rvm/gems/ruby-2.2.4/bin/rspec /home/user/workspace/auto-test/spec/pools/pool_cg_view_spec.rb --require teamcity/spec/runner/formatter/teamcity/formatter --format Spec::Runner::Formatter::TeamcityFormatter Testing started at 10:21 ... /home/user/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': incompatible library version - /home/user/.rvm/gems/ruby-2.2.4/gems/nokogiri-1.6.8/lib/nokogiri/nokogiri.so (LoadError) from /home/user/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /home/user/.rvm/gems/ruby-2.2.4/gems/nokogiri-1.6.8/lib/nokogiri.rb:32:in `rescue in <top (required)>' from /home/user/.rvm/gems/ruby-2.2.4/gems/nokogiri-1.6.8/lib/nokogiri.rb:28:in `<top (required)>' from /home/user/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /home/user/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /home/user/.rvm/gems/ruby-2.2.4/gems/capybara-2.7.1/lib/capybara.rb:3:in `<top (required)>' from /home/user/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /home/user/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /home/user/.rvm/gems/ruby-2.2.4/gems/capybara-2.7.1/lib/capybara/dsl.rb:2:in `<top (required)>' from /home/user/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /home/user/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /home/user/.rvm/gems/ruby-2.2.4/gems/capybara-2.7.1/lib/capybara/rspec.rb:2:in `<top (required)>' from /home/user/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require' from /home/user/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require' from /home/user/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require' from /home/user/workspace/auto-test/spec/support/capybara.rb:3:in `<top (required)>' from /home/user/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /home/user/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /home/user/workspace/auto-test/spec/spec_helper.rb:6:in `block in <top (required)>' from /home/user/workspace/auto-test/spec/spec_helper.rb:6:in `each' from /home/user/workspace/auto-test/spec/spec_helper.rb:6:in `<top (required)>' from /home/user/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /home/user/.rvm/rubies/ruby-2.2.4/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /home/user/.rvm/gems/ruby-2.2.4/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1295:in `block in requires=' from /home/user/.rvm/gems/ruby-2.2.4/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1295:in `each' from /home/user/.rvm/gems/ruby-2.2.4/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1295:in `requires=' from /home/user/.rvm/gems/ruby-2.2.4/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:109:in `block in process_options_into' from /home/user/.rvm/gems/ruby-2.2.4/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:108:in `each' from /home/user/.rvm/gems/ruby-2.2.4/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:108:in `process_options_into' from /home/user/.rvm/gems/ruby-2.2.4/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:21:in `configure' from /home/user/.rvm/gems/ruby-2.2.4/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:101:in `setup' from /home/user/.rvm/gems/ruby-2.2.4/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:88:in `run' from /home/user/.rvm/gems/ruby-2.2.4/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:73:in `run' from /home/user/.rvm/gems/ruby-2.2.4/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:41:in `invoke' from /home/user/.rvm/gems/ruby-2.2.4/gems/rspec-core-3.4.1/exe/rspec:4:in `<top (required)>' from /home/user/.rvm/gems/ruby-2.2.4/bin/rspec:23:in `load' from /home/user/.rvm/gems/ruby-2.2.4/bin/rspec:23:in `<top (required)>' from -e:1:in `load' from -e:1:in `<main>' Process finished with exit code 1 

If I try to run the specifications from the shell, it will work, no errors, so I think the problem is with the run configuration, but not sure what.

The launch configuration that worked so far:

enter image description here

I tried to remove the nokogiri stone and reinstall it, but still the same.

Any ideas?

Project Structure: enter image description here

+7
ruby intellij-idea rspec
source share
1 answer

You indicate that you are using ruby ​​2.2.6 when using the console. IntelliJ complains about the lack of nokogiri jewels.

I can imagine that perhaps your last bundle install did not use ruby ​​2.2.4 (as IntelliJ is used), but ruby ​​2.2.6 to install gems.

I recommend the following steps to narrow this down:

  • check and make sure that you are using ruby ​​2.2.4 on the shell (this is very important!)
  • run bundle install to make sure all the gems of your project are installed for ruby ​​2.2.4
  • run your specs in a shell

If this succeeds, try running the specification with IntelliJ. This should work if the steps described above went fine.

Personal note (not knowing if this is already the case): In my projects, I always have a .ruby-version file in the root of my project to ensure the correct ruby ​​version for the current project. You can even take one more step and add the .ruby-gemset .

More information can be found in rvm docs

+4
source share

All Articles