加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby – 在特定命名空间中测试

发布时间:2020-12-17 03:04:34 所属栏目:百科 来源:网络整理
导读:我正在尝试在命名空间中测试一些类,目前我有这样的代码: describe Server::SessionController do it "should create session" do Server::LoginController.stub(:authenitcate).and_return(session_id) Server::SessionController.... Server::SessionContr
我正在尝试在命名空间中测试一些类,目前我有这样的代码:

describe Server::SessionController do

  it "should create session" do
    Server::LoginController.stub(:authenitcate).and_return(session_id)
    Server::SessionController....
    Server::SessionController....
  end
end

如何摆脱可重复的Server命名空间?

解决方法

RSpec Book( http://pragprog.com/book/achbd/the-rspec-book)提供了一个解决方案:

3 module Codebreaker
4    describe Game do
5        describe "#start" do

… The second statement declares a Ruby module named Codebreaker.This isn’t necessary in
order to run the specs,but it provides some conveniences. For
example,we don’t have to fully qualify Game on line 4.

因此,尝试将您的规范放在服务器模块中.HTH.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读