Cannot create ruby test files (rspec or minitest).

Answered

Fairly new to ruby itself and RubyMine, so sorry for any missing info and potatoness on my side.

After creating a new Empty Project i created the following folder structure, following some advise I found on the web:

.
├── bin
│   └── runner.rb
├── lib
│   └── TaskGenerator.rb
└── spec

Now i wanted to create a test file using rspec in the spec/ folder. However when right-clicking on that folder, going New->Ruby Test I get a new dialog that only shows MiniTest and MiniTest Spec, but no option for rspec.

If i try to create a file for either of the first two it only gives me a short message saying 'The name should be a valid Ruby qualified constant' not allowing me to create a test file.

My question(s) would be:

  • What am I missing to be able to generate a rspec test file? 
  • What exactly would i need to enter as a name if I wanted to use MiniTest? I tried to find some info on that message but didn't really find anything helpful yet.

I can create an empty ruby file and fill it out manually within spec/ but that is slightly annoying to have to do that every time.

Thanks for the help in advance.

 

PS: I can run rspec tests successfully with the manually created file, so rspec seems to be installed and recognised

 

System Info:

OS: Linux Mint 19.1 Cinnamon

RubyMine 2019.3.3
Build #RM-193.6494.37, built on February 11, 2020
Licensed to [me]
Subscription is active until June 10, 2020
For educational use only.
Runtime version: 11.0.5+10-b520.38 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.19.57-041957-generic
GC: ParNew, ConcurrentMarkSweep
Memory: 1906M
Cores: 8
Registry: ide.balloon.shadow.size=0
Non-Bundled Plugins: com.chrisrm.idea.MaterialThemeUI)

Ruby: ruby-2.5.1-p57

rspec: RSpec 3.7

 

6 comments
Comment actions Permalink

Hello Christopher,

could you please specify whether rspec gem is listed in Gemfile and not highlighted there?

As for 'The name should be a valid Ruby qualified constant', which name have you set? In case of Minitest test class name looks like UserTest and it will be created if you specify User in the test creation window.

0
Comment actions Permalink

Afaik the created project does not contain a file called gemfile, i can't seem to find anything. Is the Gemfile something I need to create/generate myself?

0
Comment actions Permalink

Gemfile can be created by running 'bundler init' command. You can run it manually or via IDE (Tools - Bundler - ...)

0
Comment actions Permalink

Here you can find information about Gemfile:

https://bundler.io/v2.0/man/gemfile.5.html

0
Comment actions Permalink

I've just run into this issue, but I do have RSpec in my gemfile (and in external libraries, so.I do get the option for RSpec in the dropdown menu.

However:  I still get the error above - "The name should be a valid Ruby qualified constant" when trying to create a test file or for that matter a Ruby class or module, so the issue doesn't appear to be related to presence/absence of RSpec.

RubyMine 2019.3.3
Build #RM-193.6494.37, built on February 11, 2020
Licensed to [me]
Subscription is active until September 20, 2020
Runtime version: 11.0.5+10-b520.38 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 5.3.0-40-generic
GC: ParNew, ConcurrentMarkSweep
Memory: 725M
Cores: 4
Registry:
Non-Bundled Plugins: training

0
Comment actions Permalink

Annab, which name are you specifying that leads to the error about a valid Ruby qualified constant?

0

Please sign in to leave a comment.