21 Replies Last post: Mar 7, 2009 12:28 PM by Roman.Chernyatchik  
Mike Grafton Newbie 5 posts since
Jan 22, 2009
Currently Being Moderated

Jan 22, 2009 9:09 PM

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

Roman.Chernyatchik  JetBrains 1,448 posts since
Sep 18, 2007
Currently Being Moderated
Jan 23, 2009 3:19 PM in response to: Mike Grafton
Re: Can't run run single rspec example

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

Roman.Chernyatchik  JetBrains 1,448 posts since
Sep 18, 2007
Currently Being Moderated
Feb 12, 2009 8:33 PM in response to: Mike Grafton
Re: Can't run run single rspec example

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

Sam Ramsden Newbie 35 posts since
Aug 30, 2002
Currently Being Moderated
Feb 25, 2009 7:40 AM in response to: Roman.Chernyatchik
Re: Can't run run single rspec example

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.

Roman.Chernyatchik  JetBrains 1,448 posts since
Sep 18, 2007
Currently Being Moderated
Feb 26, 2009 12:38 AM in response to: Sam Ramsden
Re: Can't run run single rspec example

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.

Sam Ramsden Newbie 35 posts since
Aug 30, 2002
Currently Being Moderated
Feb 26, 2009 1:52 AM in response to: Roman.Chernyatchik
Re: Can't run run single rspec example

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.

Roman.Chernyatchik  JetBrains 1,448 posts since
Sep 18, 2007
Currently Being Moderated
Feb 27, 2009 11:08 PM in response to: Sam Ramsden
Re: Can't run run single rspec example

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

Michael Ward Newbie 4 posts since
Aug 20, 2002
Currently Being Moderated
Feb 26, 2009 10:09 PM in response to: Roman.Chernyatchik
Re: Can't run run single rspec example

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

Michael Ward Newbie 4 posts since
Aug 20, 2002
Currently Being Moderated
Feb 26, 2009 11:37 PM in response to: Michael Ward
Re: Can't run run single rspec example

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

James Ladd Newbie 3 posts since
Feb 28, 2009
Currently Being Moderated
Feb 28, 2009 8:31 AM in response to: Michael Ward
Re: Can't run run single rspec example

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

Roman.Chernyatchik  JetBrains 1,448 posts since
Sep 18, 2007
Currently Being Moderated
Feb 28, 2009 10:36 AM in response to: James Ladd
Re: Can't run run single rspec example

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

James Ladd Newbie 3 posts since
Feb 28, 2009
Currently Being Moderated
Feb 28, 2009 10:03 PM in response to: Roman.Chernyatchik
Re: Can't run run single rspec example

Hi Roman,

 

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

 

Rgs, James.

Roman.Chernyatchik  JetBrains 1,448 posts since
Sep 18, 2007
Currently Being Moderated
Feb 28, 2009 11:34 PM in response to: James Ladd
Re: Can't run run single rspec example

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

Brian Hartin Newbie 13 posts since
Dec 19, 2002
Currently Being Moderated
Mar 3, 2009 1:13 AM in response to: Roman.Chernyatchik
Re: Can't run run single rspec example

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.

Roman.Chernyatchik  JetBrains 1,448 posts since
Sep 18, 2007
Currently Being Moderated
Mar 3, 2009 3:04 PM in response to: Brian Hartin
Re: Can't run run single rspec example

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)

Roman.Chernyatchik  JetBrains 1,448 posts since
Sep 18, 2007
Currently Being Moderated
Feb 28, 2009 11:36 PM in response to: Roman.Chernyatchik
Re: Can't run run single rspec example

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

James Ladd Newbie 3 posts since
Feb 28, 2009
Currently Being Moderated
Mar 1, 2009 4:53 AM in response to: Roman.Chernyatchik
Re: Can't run run single rspec example

Hi Roman,

 

Thank you.

 

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

 

Rgs, James.

Roman.Chernyatchik  JetBrains 1,448 posts since
Sep 18, 2007
Currently Being Moderated
Mar 1, 2009 9:48 PM in response to: James Ladd
Re: Can't run run single rspec example

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

Roman.Chernyatchik  JetBrains 1,448 posts since
Sep 18, 2007
Currently Being Moderated
Mar 7, 2009 12:28 PM in response to: Roman.Chernyatchik
Re: Can't run run single rspec example

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.

More Like This

  • Retrieving data ...