相关疑难解决方法(0)

如何在RSpec上包含Rails助手

我试图包括一些助手用rspec测试,但没有运气.

我做了什么:

support/helpers.rb在我的spec文件夹下创建了一个文件

支持/ helpers.rb

module Helpers
  include ActionView::Helpers::NumberHelper
  include ActionView::Helpers::TextHelper
end
Run Code Online (Sandbox Code Playgroud)

并试图要求这个文件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
Run Code Online (Sandbox Code Playgroud)

这会生成以下错误:

/spec/support/helpers.rb:2:in `<module:Helpers>': uninitialized constant Helpers::ActionView (NameError)
Run Code Online (Sandbox Code Playgroud)

我应该如何使用Rspec提供这些助手?

谢谢.

tdd rspec ruby-on-rails rspec2 ruby-on-rails-3

39
推荐指数
2
解决办法
2万
查看次数

标签 统计

rspec ×1

rspec2 ×1

ruby-on-rails ×1

ruby-on-rails-3 ×1

tdd ×1