gpt4 book ai didi

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

转载 作者:数据小太阳 更新时间:2023-10-29 07:28:58 25 4
gpt4 key购买 nike

我正在尝试测试命名空间中的一些类,目前我有这段代码:

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.

因此,请尝试将您的规范放入 Server 模块中。HTH.

关于ruby - 在特定命名空间中测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14459291/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com