Add to gemspec:
# my_gem.gemspec
Gem::Specification.new do |s|
# ...
s.add_development_dependency 'minitest', "~> 2.6.1"
s.add_development_dependency 'rake'
s.add_development_dependency 'mocha'
s.add_development_dependency 'fakeweb'
end
add a test_helper:
# test/test_helper.rb
ENV["TEST"] = 'true'
require 'rubygems'
require 'minitest/autorun'
$:.unshift File.expand_path("../../lib")
require 'mygem'
require 'fakeweb'
require 'mocha'
FakeWeb.allow_net_connect = false
and a test file:
# test/configuration_test.rb
require File.expand_path('../test_helper', __FILE__)
describe "configuration" do
before do
# ...
end
it "does something" do
# ...
end
end
and to Rakefile:
require 'rake/testtask'
Rake::TestTask.new do |t|
t.libs.push "lib"
t.test_files = FileList[File.expand_path('../test/**/*_test.rb', __FILE__)]
t.verbose = true
end