Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails RSpec/Gem开发:stubing rails模板_Ruby On Rails_Ruby On Rails 3_Rubygems_Rspec - Fatal编程技术网

Ruby on rails RSpec/Gem开发:stubing rails模板

Ruby on rails RSpec/Gem开发:stubing rails模板,ruby-on-rails,ruby-on-rails-3,rubygems,rspec,Ruby On Rails,Ruby On Rails 3,Rubygems,Rspec,我目前正在开发两个不同的gem,它们都主要由rails视图助手组成 我的问题是,其中一些帮助程序需要呈现的rails模板来测试输出——但我不确定在没有rails应用程序的情况下,存根模板的最佳方法。我认为我应该能够在一定程度上利用rspec-rails,但在没有rails应用程序的情况下,我一直很难让它正常工作 我是不是走错了路?在gem开发过程中测试特定于rails的特性(特别是只在视图中发生的事情)的当前最佳实践是什么?我使用优秀的gem,它可以帮助您使用嵌入式rails应用程序设置gem框

我目前正在开发两个不同的gem,它们都主要由rails视图助手组成

我的问题是,其中一些帮助程序需要呈现的rails模板来测试输出——但我不确定在没有rails应用程序的情况下,存根模板的最佳方法。我认为我应该能够在一定程度上利用rspec-rails,但在没有rails应用程序的情况下,我一直很难让它正常工作

我是不是走错了路?在gem开发过程中测试特定于rails的特性(特别是只在视图中发生的事情)的当前最佳实践是什么?

我使用优秀的gem,它可以帮助您使用嵌入式rails应用程序设置gem框架进行测试。通过这种方式,您可以轻松地测试该应用程序中的任何rails依赖项。要生成rspec测试,请按如下方式运行它(默认为测试单元):

我所做的是将它合并到我的gem中,在某个测试文件夹中运行它,并将必要的文件复制到我的gem中。例如,您可以在内部查看它


希望这能有所帮助。

这正是我想要的。谢谢!:)
enginex -t rspec your-gem-name