在spec \ controllers \ signups_controller_spec.rb中,我有以下代码
require 'spec_helper'
describe SignupsController, :type => :controller do
describe "new - it creates a new signup at @signup" do
get :new
assigns(:signup).should be_a_new(Signup)
end
# ...
end
为了仔细检查复数问题,我的控制器确实是SignupsController。
无论如何,我在其他答案中添加了类型声明,因为我得到了未定义方法'get'的错误,我仍然得到了。有什么想法吗?
C:/Sites/GoogleTest/spec/controllers/signups_controller_spec.rb:6:in `block (2 levels) in <top (required)>': undefined method `get' for #<Class:0x4eaa748> (NoMethodError)
答案 0 :(得分:0)
这是构建规范的常用方法:
require 'spec_helper'
describe SignupsController, :type => :controller do
describe "GET new" do
it "creates a new signup at @signup" do
get :new
assigns(:signup).should be_a_new(Signup)
end
end
# ...
end
有关详细信息,请参阅official documentation。