Can't run run single rspec example

Hi!  I've got RubyMine build #638, on Mac OSX 10.5.6.

I have a brand new, freshly generated Rails app, and I then ran 'script/generate rspec'.  I have the rspec and rspec-rails gems installed (version 1.1.11).  I created a simple spec and when I run 'rake spec', it runs fine.

Here's the problem: When I right click in a spec file in RubyMine, I don't get the "Run" or "Debug" choices from the context menu. That section just isn't there, but all the other sections are present (for instance, "Rake" appears; see image below).  Also, Ctrl-Shift-F10 doesn't work (nothing happens).

I've gone into the project structure and registered 'spec' as a test directory; I've monkeyed with the default rspec run configuration; I've burned sage and chanted obscure incantations.  No luck.

Does anybody have an idea as to what's going on here?

Mike

Picture 3.png

22 comments
Comment actions Permalink

BTW, I forgot to mention that I can run  a directory of specs in RubyMine, by right-clicking on a directory from the project pane.

Mike

0
Comment actions Permalink

After more experimenting, I can get the test & debug menu options if my project has rspec and rspec-rails in vendor/plugins.  Something in RubyMine appears to care if Rspec is installed as a plugin.

The irony is that if I remove vendor/plugins/rspec and vendor/plugins/rspec-rails while RubyMine is running, and then set up my default Rspec run config to have /usr/bin/spec as the spec script, I can run specs just fine - until I restart RubyMine.  So it seems there's a bug here; I will file it.

Mike

0
Comment actions Permalink

Hi Mike,

Thanks for issue! I've created bug report in our JIRA - http://www.jetbrains.net/jira/browse/RUBY-2762. We will fix this in Next RubyMine EAP.
This problem affects only automatic generating of RSpec run configuration, thus you can always create RSpec run configuration for current file manually, although such way will be inconvenient..

0
Comment actions Permalink

No problem.  Indeed, it is prohibitively inconvenient to create a context configuration by hand every time - the beauty of ctrl-shift-f10 is it's convenience.

Thanks for filing the bug.  I added a comment since I have seen it working fine in other Rails projects without rspec and rspec-rails in vendor/plugins.  I will try to isolate the differences between when it works and when it doesn't...

0
Comment actions Permalink

Hi Mike,

It seems we've fixed the issue. Also for enabling RSpec support your *_spec.rb file should require 'spec' script. E.g.


# my_spec.rb
require 'spec'

describe ... do
  #...
end




The require may be indirect, e.g. you can require 'spec_helper' script, which requires 'spec' script. Thus if RubyMine doesn't understand your require and can't resolve it to appropriate ruby script RSpec support will not be enabled for your file. Also check that ''RSpec" gem is attached to your project in RubyMine's Gem Manager settings.

Fix will be available in next RubyMine EAP

0
Comment actions Permalink

When do you expect a fix for this to be released?
I have just installed IDEA 9732 with Ruby Plugin 2.0.223960 and have this issue.

0
Comment actions Permalink

Hi Sam,

That bug was fixed 2 weeks ago and has been already released.

I suppose that in your case rspec gem isn't attached to your Idea module with ruby support (thus ruby plugin doesn't understand that your spec example is rspec example block).

Last builds of RubyMine and Ruby Plugins includes  Gem Manager support. Such approach allows as to parse and keep in memory only necessary gems (i.e. previous versions of Ruby plugin/RubyMine kept in memory whole ruby core libraries with all gems available in disk)  For RubyMine we implemented special UI for Gem Manager that allows to activate, browse remote gems and install them from the network. In case of Ruby Plugin for attaching gems to Idea project's module we decided to reuse standard IDEA's notion of Libraries and Dependencies (instead of providing special UI such as we have in RubyMine). Thus our Ruby SDK automatically creates Libraries for its gems and then user / Ruby Plugin can attach only necessary gems to module . Unfortunately it seems our UI in case of Ruby plugin isn't user friendly thus we decided to port our GemManager UI from RubyMine to Ruby Plugin. Now we are testing this ported UI and we are going to update plugin in a two or three days.

Sorry for inconvenience.

0
Comment actions Permalink

So from what you're saying all I need to do is ensure that I have (for example) Global Libraries such as...
[gem] rspec (v1.1.12, /home/sam/dev-helper/jruby-1.1.6/lib/ruby/gems/1.8/gems/rspec-1.1.12
then ensure that the rspec gems (one also for rails-rspec) are included in my module's dependency list?

I have tried this and it's not working for me.  I did notice that other gems had been picked up automatically and I must have installed the rspec gem after declaring the JRuby SDK to IDEA.  Perhaps if I just unload and reload the JRuby SDK I may have some luck.

0
Comment actions Permalink

I'm seeing the exact same issue as Sam.  I am not quite clear on how to resolve this issue in IDEA based on what you have written.  Could you please clarify what steps are necessary to run rspec tests?

Thanks,
Mike

0
Comment actions Permalink

Ok I now see how this work in IntelliJ.  It appears that gems get added automatically to the Global Libraries, at least they did for JRuby.  Then you must add the gem (i.e. rspec) to that modules list of dependencies.

Hope that helps others.

--Mike

0
Comment actions Permalink

Ok, I've reproduced it. You are right it really is broken. I've created issue http://www.jetbrains.net/jira/browse/RUBY-3104.

0
Comment actions Permalink

>>Ok I now see how this work in IntelliJ.  It appears that gems get added automatically to the Global Libraries, at least they did for JRuby.  Then you must add the gem (i.e. rspec) to that modules list of dependencies.


Can someone please outline the steps needed to get rspec working in IntelliJ ?
How do you see/get the gems added to the Global Libraries and how do you add them to the modules liet of dependencies?

Thanks in advance.

Rgs, James.

0
Comment actions Permalink

Hi James,
1. Open "Project Structure | JDKs".
2. If Ruby/JRuby SDK doesn't exist in sdks list - create new Ruby/JRuby SDK and press Apply button
3. Check that it automatically generated global libraries for all your gems. Names of this libs will be  "[gem] *** ".
4. Open "Project Structure|Modules" tab, select your Ruby/(Java module with JRuby facet), open "Dependencies" tab
5. Press "Add" button at the right side of "Dependencies" tab and choose "4. Global library..."
6. Select lib with name "[gem] rspec (v.1.x.x, $path)" and "[gem] rspec-rails (...)". Close dialog with OK button
7. Press Apply

0
Comment actions Permalink

Hi Roman,

Thank you for a detailed response. I'll try the steps and post the results.

Rgs, James.

0
Comment actions Permalink

Also for installed Rspec/RSpec on Rails plugins should work without additional settings

0
Comment actions Permalink

Gem manager is still buggy in Ruby plugin. We will continue it's improving after weekend.

0
Comment actions Permalink

Hi Roman,

Thank you.

All appears to be working after applying your steps. I blogged about it here to help others.

Rgs, James.

0
Comment actions Permalink

James,
Nice post, thanks! By the way have you tried our RubyMine IDE? This IDE is based on IntelliJ IDEA platform has the same features as Ruby plugin (except JRuby <-> Java integration), also VCS support, git, html, xml, js etc. Now it is available for free in our EAP (early access program), see http://www.jetbrains.net/confluence/display/RUBYDEV/RubyMine+and+IntelliJ+IDEA+Ruby+Plugin

0
Comment actions Permalink

I have an existing project, so I deleted the Ruby SDK and added a new one, but it does not create global libraries for my gems.  I had to do it by hand, and here is what I did:

  • Opened my existing project
  • Chose 'File' -> 'Project Structure'
  • Chose 'Platform Settings / JDKs'
  • Deleted by Ruby SDK
  • Added a new Ruby SDK
  • Clicked 'Global Libraries'
  • Clicked '+' to add a new library
  • The naming convention for the library seems to be "[gem] GEMNAME (v.GEM_VERSION, GEM_PATH)", so for 'rails' I have
    • [gem] rails(v.1.2.5, c:\ruby\lib\ruby\gems\1.8\gems\rails-1.2.5)
  • Clicked 'Project Settings / Modules'
  • Selected the module
  • Selected the 'Dependencies' tab
  • Clicked 'Add...'
  • Chose 'Global Library...'
  • Chose the library I just added for rails


Still not able to run tests...I got Error running test_foo: File 'test/unit/autorunner.rb' wasn't found in $LOAD_PATH of Ruby SDK with interpreter: '{1}'.  I noticed that the 'class path' of the SDK was blank, which is different than what I had seen before I deleted and re-added the SDK.  To solve that, I had to:

  • Add a second SDK.
  • Manually add all the 'class path' entries to the first SDK, using the second as a guide.
  • Delete the second SDK.


Now I can finally run my tests and my server.

0
Comment actions Permalink

bjhartin wrote:

  • Deleted by Ruby SDK
  • Added a new Ruby SDK

Did you press "Apply" button before adding new SDK and after it? (RubyMine will create gem's libraries only if you save your new SDK)

0
Comment actions Permalink

We've updated Ruby plugin. Now Gem Manager UI is available and it allows to install/attach gems to project  instead of manually adding gem's libraries to module Dependencies tab.

0
Comment actions Permalink

I ran into this error as well. I ended up resolving it by opening a terminal and running "gem update test-unit". I use Rbenv and some of the bin scripts need to be "rehashed" so I also ran an "rbenv rehash". Not sure if the rbenv step is strictly necessary, but this resolved my issue. I now have

$ gem list test-unit

*** LOCAL GEMS ***

test-unit (3.2.6, 2.1.5.0)
$ ruby -v
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin15.0]

0

Please sign in to leave a comment.