私はいくつかのビューヘルパーを定義するrails3railtieを書いています。モジュールをインスタンス化できないため、ビューヘルパーメソッドをどのように指定するのか疑問に思います。私はすでにたくさん検索して読んでいますが、それを機能させることができませんでした。
view_helper_spec.rb
require 'spec_helper'
module MyRailtie
describe ViewHelper, :type => :helper do
describe "style_tag" do
it "should return a style tag with inline css" do
helper.style_tag("body{background:#ff0}").should ==
body{background:#ff0}
EOT
end
end
end
end
「ヘルパー」が定義されていないことを常に不平を言います。:type =>:helperは何もしないようです。
gemspecには、開発/テストモードのrspecおよびrspec-railsgemが必要です。