简体   繁体   English

将Ruby-Lint与Rspec集成

[英]Integrate Ruby-Lint with Rspec

I have a Rails 4.2 project that uses Bundler and Rspec. 我有一个使用Bundler和Rspec的Rails 4.2项目。 I want ruby-lint to work with my specs. 我希望ruby-lint能够使用我的规格。 By default it doesn't: 默认情况下不会:

$ ruby-lint spec/models/user_spec.rb 
user_spec.rb: error: line 3, column 1: undefined constant RSpec
user_spec.rb: error: line 4, column 3: undefined method describe
user_spec.rb: error: line 5, column 5: undefined method let

I have require 'rails_helper' in spec/models/user_spec.rb so it is natural to expect that ruby-lint would load it and therefore load rspec . 我在spec/models/user_spec.rb require 'rails_helper' ,因此很自然地期望ruby-lint会加载它并因此加载rspec

What should I do in order to make ruby-lint handle spec files correctly? 我应该怎么做才能使ruby-lint正确处理spec文件?

PS I don't have any specific ruby-lint configuration. PS我没有任何特定的ruby-lint配置。

PPS I have the same question for the Gemfile file. PPS我对Gemfile文件有同样的问题。

PPPS Actually I need it in order to get error checking in vim via synstastic or neomake. PPPS实际上我需要它来通过synstastic或neomake在vim中进行错误检查。

I have only used ruby-lint sparingly (because of the many false negatives it gives). 我只是谨慎地使用了ruby-lint(因为它给出了许多假阴性)。 So I am no expert unfortunately. 不幸的是,我不是专家。

I suppose you want to use it in some automated way, because from the command line you can just point it to the directory that you need. 我想你想以某种自动方式使用它,因为从命令行你可以将它指向你需要的目录。

Looking at the code you can put the directories that you want to lint in a config file. 查看代码,您可以将您想要的目录放在配置文件中。 I think something like the following entry should work: 我认为以下条目应该有效:

directories: ['lib']

See example config.yaml and example rspecs and of course the relevant config code . 请参阅示例config.yaml示例rspecs ,当然还有相关的配置代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM