pic*_*rdo 18 testing rspec routes ruby-on-rails-3
我是新的Rspec,刚开始在Rails 3上生成一个新的控制器.它默认生成一些Rspec测试.我有一个关于如何使它们通过的问题.就目前而言,我在终端上看到了这个测试"
1)BuildingsController GET'show'应该是成功的
Run Code Online (Sandbox Code Playgroud)Failure/Error: get 'show' No route matches {:controller=>"buildings", :action=>"show"} # ./spec/controllers/buildings_controller_spec.rb:17:in `block (3 levels) in <top (required)>'
但是,我不明白为什么它会出现,因为我已经创建了这条路线("资源:建筑物"),我跑了rake routes并确保它在那里.
建设GET /buildings /:id(.:format){:action =>"show",:controller =>"buildings"}
这通过什么是必要的?以下是测试:
  describe "GET 'show'" do
    it "should be successful" do
      get 'show'
      response.should be_success
    end
  end
Hei*_*kki 38
你需要传递现有建筑的id: get :show, :id => @building.id
路线抱怨它,因为:id不是可选的.
| 归档时间: | 
 | 
| 查看次数: | 11377 次 | 
| 最近记录: |