2013-02-13 43 views
1

我正在使用Rspec,我想测试位于另一个模块内的模块内的控制器。测试模块内的控制器

module Food 
    module Fruit 
    class ApplesController < ApplicationController 

    etc... 

目前,我有我的RSpec的文件apples_controller_spec.rb看起来像

require 'spec_helper' 

    describe ApplesController do 

    etc.. 

什么是关于对Rspec的命名约定,以测试控制器,其两个模块内,因为目前我得到一个错误, uninitialized constant BurstsController (NameError)

回答

2

您需要:

require 'spec_helper' 
module Food 
    module Fruit 
    describe ApplesController do 

,或者你可以这样做:

require 'spec_helper' 

describe Food::Fruit::ApplesController do 

我个人使用前者。

+0

啊。在提出问题之前,我尝试了后者。并没有奏效。意识到我的模块名称过于庞大。它又一次,它的工作!感谢您的其他选择。 – jason328 2013-02-13 20:20:12