Я новичок в программировании и извините, если это глупый вопрос.Я пишу тест для контроллеров в Ruby on Rails.Тест ожидает параметр, но я не уверен, как это сделать.Когда я запускаю тест с помощью rspec, я получаю сообщение об ошибке, которое вы видите в заголовке.
Это часть кода контроллера:
class DemographicDetailController < ApplicationController
#before_filter :authorize
include ::Demographic
def show
@cinema_id = params[:cinema_id]
@cinema = Cinema.find(@cinema_id)
@cinema_name = @cinema.name
@cinmea_address = @cinema.address.full_street_address
@cinema_authority_id = @cinema.address.post_code.local_authority_id
@c_working_age = Population.where(:local_authority_id => @cinema_authority_id , :year => Population.maximum("year")).first
@c_working_age = @c_working_age.working_age_16_to_64
@c_total_population = totalpopulation(@cinema_authority_id)
@c_average_income = latestaverageincome(@cinema_authority_id)
@all_cinemas = Cinema.all
(...)
end
, и это тест, который я написал для метода show:
describe "Demographic" do
context "when testing the DemographicDetail controller" do
#let(:params) { { disabled: false } }
let(:cinema_id) { create(:cinema) }
it "should show demoraphic details successfully" do
get :show, params: { id: @cinema_id }
assert_response :success
end
end
Это маршрут:
controller :demographic_detail do
get '/demographic_detail/show/:cinema_id' => :show
end