Rails Mountable Engine 的项目应该如何实现测试呀

wuwx · May 01, 2013 · Last by zlx_star replied at May 01, 2013 · 2610 hits

问这个问题的时候我已经很无力了,今天折腾了一天,各种受挫……,现在又遇到路由问题……

rails plugin new xiaozu --mountable

Xiaozu::Engine.routes.draw do
  resources :groups
end
require 'test_helper'

module Xiaozu
  class GroupsControllerTest < ActionController::TestCase

    setup do
      @group = xiaozu_groups(:one)
    end

    test "should get index" do
      get :index
      assert_response :success
      assert_not_nil assigns(:groups)
    end
  end
end

他居然报错啊报错啊:

test_should_get_index(Xiaozu::GroupsControllerTest):
ActionController::RoutingError: No route matches {:controller=>"xiaozu/groups"}

这个该怎么解决啊……太 DT 了…… 还有如果想把项目弄到 Engine 里,都要注意什么啊,坑太多了……

dummy app.

#1 楼 @zgm 在 dummy app 下执行 rake 木有反应啊

mbp:dummy wwx$ rake
mbp:dummy wwx$ rake test
mbp:dummy wwx$

#3 楼 @SharpX 亲,我用 TestCase 呀

不知道你理解的 dummy 是不是一样,但是测试主要是模拟实际情况: 可以参照一下: cell 或者一个简单版本:left_side

虽然用的都是 rspec 但是原理应该差不多。希望对你有帮助

You need to Sign in before reply, if you don't have an account, please Sign up first.