【发布时间】:2017-01-05 15:01:16
【问题描述】:
我对 Ruby 和 RSpec 非常陌生。我想为这个模块创建基本的规范文件:
module DownloadAttemptsHelper
def download_attempt_filter_select_options
search_types = [
[I18n.t("helpers.download_attempts.search_types_default"), 'default' ],
[I18n.t("helpers.download_attempts.search_types_account_id"), 'account_id' ],
[I18n.t("helpers.download_attempts.search_types_remote_ip"), 'remote_ip' ],
]
options_for_select(search_types)
end
end
小测试
describe DownloadAttemptsHelper do
it "does something" do
expect(1).to be_odd
end
end
我明白了:
`<top (required)>': uninitialized constant DownloadAttemptsHelper (NameError)
我需要导入目录路径和模块名称吗? 你能给我一些非常基本的例子来测试这个模块吗?
【问题讨论】:
-
网上有很多教程和指南,怎么写specs,你试过吗?
-
是的,但是我对这种语言太陌生了。请给我一些基本的例子好吗?
-
它不是一种语言,它是一个测试框架。这是来自谷歌的第一个链接。 codeschool.com/courses/testing-with-rspec
标签: ruby-on-rails ruby rspec