在我的 Rails 应用程序中,ruby 2.6.5,rails 6.1。我使用 Active admin 并创建了此页面。如何使用 rspec 为此创建一些测试? 我已经为模型和控制器创建了测试。
ActiveAdmin.register BxBlockTermsAndConditions::TermsAndCondition, as: "TermsAndConditions" do
permit_params :description, :account_id
index do
selectable_column
id_column
column :account_id
column :description
column :created_at
column :updated_at
actions
end
form do |f|
f.inputs do
f.input :account_id, label: "Conta"
f.input :description
end
f.actions
end
show do
attributes_table do
row :id
row :account_id
row :description
row :created_at
row :updated_at
end
end
end
有人可以帮助我吗?
如何测试页面
这是一个正常的请求规范。例如,如果你想测试索引动作
RSpec.describe Admin::TermsAndConditionsController, type: :request do
let(:admin_user) { create(:admin_user) }
before { sign_in admin_user }
describe "GET" do
it 'index returns http success' do
get main_app.admin_terms_and_conditions_path
expect(response).to be_successful
end
end
end
检查您的
rails/routes
以确保路径