0
Я использую Rails 4.1, и у меня есть API json, но не работает на Rspec-Rails.Нет совпадений маршрутов в Rspec Rails
RSpec рельсы - Версия 3.2.1 используется
$ рейк маршруты
GET /cities/:code(.:format) cities#show
cities_controller.rb
class CitiesController < ApplicationController
respond_to :json
def show
code = params[:code]
respond_with City.find_by_code(code)
end
end
cities_controller_spec.rb
require 'rails_helper'
RSpec.describe CitiesController, :type => :controller do
describe "GET city" do
it "should be ok" do
get '/cities', :code => 'DUB', :format => :json
expect(response).to be_success
expect(response).to have_http_status(200)
end
end
end
Когда execut I e rspec, я принимаю это
Failure/Error: data = get '/cities', :code => 'DUB', :format => :json
ActionController::UrlGenerationError:
No route matches {:action=>"/cities", :controller=>"cities", :code=>"DUB", :format=>:json}
Любые идеи?
Спасибо!
Спасибо, fivedigit, те же ошибки, о которых нет Маршрутные совпадения {: action => "/ cities",: controller => "cities",: code => "DUB",: format =>: json} – Alexander
У меня не было заметил это, когда я ответил, но я думал, что ваше действие на самом деле называется «городами», а не шоу. Обновление моего ответа. – fivedigit
Прекрасно работает! Большое спасибо fvedigit: D – Alexander