【发布时间】:2012-12-13 13:26:40
【问题描述】:
我正在尝试从我的一个规范助手中的模块访问方法
我将模块包含在测试助手中
module Support
class RestHelper
include Rest::Rest
def create_rest_client_for_ifa
# Call method from module
create_rest_client(uname, pword)
end
end
end
但是当我运行我的规范时,我不断收到 NoMethodError:
Failure/Error: @rest_client = Support::RestHelper.create_rest_client_for_ifa
NoMethodError:
undefined method `create_rest_client' for Support::RestHelper:Class
这是我的模块代码:
module Rest
module Rest
.
.
def create_rest_client(uname, pword)
# code
end
.
.
end
end
当我在 rails 控制台中测试时,它似乎工作正常
$ RAILS_ENV=test rails c
irb> include Rest::Rest
=> Object
irb> create_rest_client(uname, pword)
我错过了什么?为什么我无法从测试助手访问方法?
任何帮助将不胜感激。
【问题讨论】:
标签: ruby ruby-on-rails-3 module nomethoderror