Merbのプラグインを作る場合、merb-gen plugin plugin-name でひな形が生成されますが、現状では生成されるspecがほとんど空っぽなので、
ちゃんとしたspecを書くための足場の作り方を紹介します。

まずは、spec/spec_helper.rb を以下のような感じに準備します
(これはdm-has-versionsの例です)

ruby>>
$:.push File.join(File.dirname(FILE), '..', 'lib')

require 'rubygems'
require 'merb-core'
require 'dm-core'
require "spec"
require 'dm-has-versions/has/versions'
require 'dm-aggregates'

DataMapper::Model.append_extensions DataMapper::Has::Versions
Merb.disable(:initfile)
Merb.start_environment(
:testing => true,
:adapter => 'runner',
:environment => ENV['MERB_ENV'] || 'test',
:merb_root => File.dirname(FILE) / 'fixture',
:log_file => File.dirname(FILE) / "merb_test.log"
)
DataMapper.setup(:default, "sqlite3::memory:")

Spec::Runner.configure do |config|
config.include(Merb::Test::ViewHelper)
config.include(Merb::Test::RouteHelper)
config.include(Merb::Test::ControllerHelper)

DataMapper.auto_migrate!
end
<<--

この例では、DataMapperを使う事を前提としています。
"sqlite3::memory:" を指定することで、テストのための
データベースファイルなどを用意する必要がないので楽です。

テストで利用されるクラス群は、spec/fixture 以下に、
通常のMerbアプリケーションと同様のディレクトリ階層で用意します。

pre>>
% tree spec/fixture [~/project/dm-has-versions:master]
spec/fixture
-- app -- models
|-- comment.rb
`-- story.rb
<<--

posted by genki genki on Fri 16 Jan 2009 at 12:16 with 0 comments
Contents rssrss
光ファイバーを二次元振動させて走査するAR用ディスプレイ
因果の取り違え
Swift2's defer for CoffeeScript
mongodb-3.0からcreateIndexのdropDupsが無くなったらしい
mongodb-3.0以降のWiredTigerの設定を動的に変更する方法
一般楕円の高速生成アルゴリズムへの道標
farro mantecatoのレシピ
Droonga関連の記事のまとめ
RuntimeErrorの特定のメッセージに限定してrescueする方法
jQueryでscriptタグを実行せずにappendする
Tags
coffeescriptdefergroongajsmemonodenodejs
Comments rssrss
https://businessrost.ru/bitrix/redirect.php?goto=http%3A%2F%2Feximha.ch%2Fblog%2Findex.php%3Fid%3Dz85yj914%26abuse%3D1636 https://businessrost.ru/bitrix/redirect.php?goto=http%3A%2F%2Feximha.ch%2Fblog%2Findex.php%3Fid%3Dz85yj914%26abuse%3D1636: I have to thank you for the efforts you have put ... 04/26 06:43
http://ldm.sakura.ne.jp/balu+bbbs/album/album.cgi?mode=detail&no=210 http://ldm.sakura.ne.jp/balu+bbbs/album/album.cgi?mode=detail&no=210: Aw, this was an incredibly good post. Taking the t... 04/25 18:19
https://www.bigbeargum.com/2019/02/15/ambrose-redmoon/ https://www.bigbeargum.com/2019/02/15/ambrose-redmoon/: Hello would you mind letting me know which hosting... 04/25 17:39
http://zeroken.jp/1978td/album/album.cgi?mode=detail&no=20 http://zeroken.jp/1978td/album/album.cgi?mode=detail&no=20: Asking questions are genuinely fastidious thing if... 04/25 17:26
https://natucci-estetica.com/?attachment_id=1376 https://natucci-estetica.com/?attachment_id=1376: Hello there, You have done a fantastic job. I wi... 04/25 17:05
https://www.waimaoz.com/23019.html?unapproved=5151&moderation-hash=a14b2a811444fc3059edb7c1441d076e https://www.waimaoz.com/23019.html?unapproved=5151&moderation-hash=a14b2a811444fc3059edb7c1441d076e: Good day! Do you use Twitter? I'd like to follow y... 04/25 16:50
https://bysystem.ru/process-proizvodstva-kartonnyh-korobok-i/ https://bysystem.ru/process-proizvodstva-kartonnyh-korobok-i/: Требовалось производство картонных коробок в сжа... 04/25 15:33
https://marialionsa.ru/proizvodstvo-kartonnyh-korobok-i-upakovki/ https://marialionsa.ru/proizvodstvo-kartonnyh-korobok-i-upakovki/: Документооборот четкий, все закрывающие акты предо... 04/25 15:05