Inspection incorrectly warns about number of arguments

I have a test like:

    it 'has a valid factory' do
      assert create(:widget).valid?
    end

The line with `create` is underlined in red.  Mousing over, it says: "Found 1 extra argument(s)".  The method actually being used is FactoryGirl.create, which accepts any number of arguments.

    def create(name, *traits_and_overrides, &block)

Now, it's not reasonable to expect the static analysis to know that I'm using FactoryGirl.create, as it is included at runtime:

    class ActiveSupport::TestCase
      include FactoryGirl::Syntax::Methods
    end

So, do I have to disable this inspection?  I'd rather not, as it's useful in most other situations, but I can't have every third line of my tests underlined in red.

I am using rubymine 6.3.3

Thanks!

0
2 comments

Hi,

unfortunately, we do not understand FactoryGirl's magic yet :(
Feel free to vote for https://youtrack.jetbrains.com/issue/RUBY-5014.

For now I'd suggest to disable the inspection for entire test file.

Regards, Oleg.

0

> unfortunately, we do not understand FactoryGirl's magic yet :(

That's fine.  I'd be really impressed if you did!

> For now I'd suggest to disable the inspection for entire test file.

I discovered scopes, and disabled the inspection for the "Test Files" scope!  Thanks for the tip!

It's funny how the depth of configuration options is so inconsistent.  Sometimes it's amazingly deep, like these scoped inspections, and sometimes the simplest features, like saving a file (https://devnet.jetbrains.com/thread/458340?tstart=0) are missing.

Anyway, thanks!

0

Please sign in to leave a comment.