如何使用Rspec和Cucumber创建和测试gem

时间:2021-08-23 23:15:10

I have created a model that I use across applications.

我创建了一个跨应用程序使用的模型。

module WeblabOnRails
  class TimeOnly
    #...
  end
end

I put the code in my lib/weblab_on_rails/time_only.rb and I invoke it, each time from application.rb.

我把代码放在我的lib / weblab_on_rails / time_only.rb中,每次都从application.rb调用它。

I would like to integrate that code into a gem and write tests using Rspec and Cucumber. I am using Rails 3.2.5.

我想将该代码集成到gem中,并使用Rspec和Cucumber编写测试。我正在使用Rails 3.2.5。

1 个解决方案

#1


1  

I recommend you using bundler to create and publish gems. Check out this RailsCast: http://railscasts.com/episodes/245-new-gem-with-bundler. Once you created your gem project you can use RSpec, Cucumber or whatever to test it.

我建议您使用bundler来创建和发布gem。看看这个RailsCast:http://railscasts.com/episodes/245-new-gem-with-bundler。创建宝石项目后,您可以使用RSpec,Cucumber或其他任何东西进行测试。

#1


1  

I recommend you using bundler to create and publish gems. Check out this RailsCast: http://railscasts.com/episodes/245-new-gem-with-bundler. Once you created your gem project you can use RSpec, Cucumber or whatever to test it.

我建议您使用bundler来创建和发布gem。看看这个RailsCast:http://railscasts.com/episodes/245-new-gem-with-bundler。创建宝石项目后,您可以使用RSpec,Cucumber或其他任何东西进行测试。