Séb*_*oon 5 routing controller rspec ruby-on-rails-3
在这种情况下,我觉得代码说的不仅仅是单词,所以放在代码中:
配置/ routes.rb中
namespace :embed do
namespace :v1 do
resources :articles
end
end
Run Code Online (Sandbox Code Playgroud)
应用程序/控制器/嵌入/ V1/articles_controller.rb
class Embed::V1::ArticlesController < ApplicationController
def index
render :text => 'ok'
end
end
Run Code Online (Sandbox Code Playgroud)
规格/控制器/嵌入/ V1/articles_controller_spec.rb
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Embed::V1::ArticlesController do
it "should do something" do
get :new
end
end
Run Code Online (Sandbox Code Playgroud)
运行 rspec spec
$ rspec spec
F
Failures:
1) Embed::V1::ArticlesController should do something
Failure/Error: get :new
AbstractController::ActionNotFound:
The action 'new' could not be found for Embed::V1::ArticlesController
# ./spec/controllers/embed/v1/articles_controller_spec.rb:5
Finished in 0.01665 seconds
1 example, 1 failure
Run Code Online (Sandbox Code Playgroud)
知道为什么会这样吗?有嵌套限制吗?访问URL http://0.0.0.0:3000/embed/v1/articles按预期呈现正常.