RobertJoseph RobertJoseph - 5 months ago 32
Ruby Question

How to check entire rails project for compilation errors

I am new to ruby and rails. I am used to working in IDEs (Xcode, Visual Studio, etc.) where I can perform project-wide/workspace-wide "build/compile" operations.

Let's say that I modify a number of ruby files in my rails project. I haven't yet written tests that will exercise all of my changes.

Is there a way to ensure that all of my *.rb files compile without directly exercising them at runtime? I'd really just like to perform a "compile all of my ruby/erb files" operation so that I know that I don't currently have any syntax errors.

UPDATE

I probably should have mentioned that I've been writing code professionally for 20 years. I realize that Ruby isn't compiled like, say, C++, but that doesn't mean that its syntax can't be checked. In my case, I've decided to use ruby-lint to catch basic syntax errors without having to exercise the code at runtime.

Answer

Ruby is an interpreted language. There is no compilation step. Please follow TDD and write your tests before you write your code.

UPDATE: Since this answer was accepted, I can't delete it unless the OP accepts another answer but people landing here through Google search, please see the other answers. This was more of a tongue in cheek remark than an answer. Ruby community has wonderful tools for doing all kinds of static code analysis like Rubocop and friends. At the bare minimum, ruby -c will accomplish what the OP wanted.