欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

how to test gem

程序员文章站 2024-03-11 16:40:55
...

I wrote some gems in my project, but testing them is a big pain.

Everytime I want to make sure all functions work, I need to make a test model outside gem and test there.

 

Here is one solution:

make a spec folder in gem.

Take test string_extension.rb as example.

 

In spec/string_extension_spec.rb add environment:

 

require "../lib/extensions/string_extension.rb"
require 'rubygems'
require 'active_support'
require 'active_support/inflector'

 

Ok, then write you test code as will.

相关标签: rubygems