我有这样的版本路线
api_version(:module => "api/v1", :path => "api/v1") do
match '/files' => 'files#index', :via => :get
end
还有我的控制器 app/controllers/api/v1/files_controller.rb
class Api::V1::FilesController < ApplicationController
def index
end
end
根目录/spec/controllers/api/v1/files_controller_spec.rb 中的规范
require 'spec_helper'
describe Api::V1::FilesController do
describe "routing" do
it "should routes to version-1 api" do
expect(:get => "/api/v1/files").to route_to("api/v1/files#index")
end
end
end
命令 rake routes 给了我这样的路线列表
devise/registrations#edit
PUT /users(.:format) devise/registrations#update
DELETE /users(.:format) devise/registrations#destroy
api_v1_files GET /api/v1/files(.:format) api/v1/files#index
当我运行 rake spec:controllers 时,规格下降。
F
Failures:
1) Api::V1::FilesController routing should routes to version-1 api
Failure/Error: Unable to find matching line from backtrace
NoMethodError:
undefined method `[]' for nil:NilClass
# /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/moped-1.2.7/lib/moped/node.rb:74:in `block in command'
# /home/dilshod/.rvm/gems/ruby-1.9.2-p290/gems/moped-1.2.7/lib/moped/n
我做错了什么?