为了加快开发和调试过程
Given I have some rspec output in my console with file path and line numbers
When I click on the file name and line number within the console
Then I want my editor to open and scroll the cursor to the specified line
我目前在 Ubuntu 11.10 上使用 Sublime-Text-2 并运行 Rspec2 的自动测试功能。
最佳答案
我相信您应该能够利用 sublime text 的构建系统中内置的功能,借助错误捕获功能来做到这一点。尽管我不能 100% 确定是否支持点击。
有一些文档 here和 here关于设置它们。如果您深入研究 sublime text 提供的默认包,应该能够找到更多示例。
你会想要制作一个生成系统来生成你的 rspec cmd。在构建配置中,您需要特别注意 "file_regex"
键。这将允许您定义一个正则表达式来捕获 cmd
的错误输出。
文档是这样说的:
file_regex 选项使用 Perl 风格的正则表达式从构建程序的输出中捕获最多四个字段的错误信息,即:文件名、行号、列号和错误消息。在模式中使用组来捕获此信息。文件名字段和行号字段是必需的。
When error information is captured, you can navigate to error instances in your project’s files with F4 and Shift+F4. If available, the captured error message will be displayed in the status bar.
此外,您也许可以在 sublimetext forums 获得更多关注关于细节。
关于ruby - 如何直接从控制台中的 rspec 输出打开编辑器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8279291/