Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unresolved ruby reference in RubyMine

Is there any way to avoid the "unresolved ruby reference" warning in RubyMine IDE? for example, when some code in my view calls a method of the view helper, I get the "unresolved ruby reference" warning even though the code works.

The case described above is just one of many. Another example is when using RSpec:

  it "should require an email" do
    no_email_user = User.new(@attr.merge(:email => ""))
    no_email_user.should_not be_valid
  end

the parameter "be_valid" is not known to the RubyMine IDE.

My question is - is there any way to solve this? should I require additional files? should I do something differently? Those false positives regarding unresolved ruby methods/constants are really disturbing, and it also affects the results of the "find usages" action in RubyMine.

I'm using RubyMine 3.1 I would really appreciate any help in resolving this issue.

like image 546
Rubinsh Avatar asked Mar 08 '11 07:03

Rubinsh


2 Answers

This issue is already submitted to the RubyMine bug tracker, please watch/vote.

like image 59
CrazyCoder Avatar answered Sep 28 '22 20:09

CrazyCoder


I think in this case this is hard to solve. Ruby allows great magic to happen using method_missing and as far as i know, the be_valid is also implemented in this way. Actually there is no be_valid but it calls the valid? method and expects it to be true.

In rspec, this work for any method ending in a ?. So if you have a method ready?, you can write should be_ready.

I am a fulltime Rubymine user, but i do not know how they could solve that nor do i expect it.

like image 24
nathanvda Avatar answered Sep 28 '22 19:09

nathanvda