【发布时间】:2012-02-25 15:39:14
【问题描述】:
我正在尝试包含一些帮助程序来使用 rspec 进行测试,但没有运气。
我做了什么:
在我的spec 文件夹下创建了一个support/helpers.rb 文件。
support/helpers.rb
module Helpers
include ActionView::Helpers::NumberHelper
include ActionView::Helpers::TextHelper
end
并尝试在spec_helper.rb 中要求此文件。
# This file is copied to spec/ when you run 'rails generate rspec:install'
require 'rubygems'
require 'spork'
require 'support/helpers'
Spork.prefork do
.
.
end
这会产生以下错误:
/spec/support/helpers.rb:2:in `<module:Helpers>': uninitialized constant Helpers::ActionView (NameError)
我应该如何使用 Rspec 来使用这些帮助程序?
谢谢。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 rspec tdd rspec2