how to test gem

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)