Cannot create ruby test files (rspec or minitest).
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
请先登录再写评论。
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.
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?
Gemfile can be created by running 'bundler init' command. You can run it manually or via IDE (Tools - Bundler - ...)
Here you can find information about Gemfile:
https://bundler.io/v2.0/man/gemfile.5.html
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
Annab, which name are you specifying that leads to the error about a valid Ruby qualified constant?
Annab, I'm a bit late, but I was running into the same problem, and discovered that Rubymine enforces the file name for RSpec tests being in qualified constant name, i.e., the firs letter have to be upper case. So you enter something like ListingArticle to create an RSpec file and the Rubymine will not complain about, as you entered a qualified constant name. That name will be in the describe section of the file stub generated, but the file per se will have the name listing_article_spec.rb.
Ahh, thanks Cassiano! That is really useful to know - it makes sense now.
Probably a bit late, but just to leave a proper answer:
In file creation Mine requires the names of specs to be in valid constant form, which by default has to follow Camel Case even if the generated file name ends up in snake case.
So, for : 'test_something_spec.rb'
The name informed should be:
'TestSomethingSpec'