我正在尝试使用rspec测试ActiveAdmin中的自定义成员操作。
应用程序/管理员/非活动用户。rb型
ActiveAdmin.register InactiveUser do
member_action :activate, method: :put do
user = User.new(email: resource.email, password: generate_activation_code)
resource.destroy if user.save
send_activation_email user
redirect_to admin_inactive_users_path, notice: "#{user.email} was activated"
end
end
require 'spec_helper'
describe Admin::InactiveUserController do
render_views
before do
@admin = FactoryGirl.create(:admin, confirmed_at: Date.yesterday)
authenticate_user @admin
end
describe "PUT #activate" do
before(:each) do
@inactive_user = FactoryGirl.create(:inactive_user)
put :activate, id: @inactive_user.id
end
it "should redirect to inactive users index" do
expect(response).to redirect_to(admin_inactive_users_path)
end
end
end
我遇到了这个错误:
NameError:
uninitialized constant Admin
# ./spec/admin/inactive_user_controller_spec.rb:3:in `<top (required)>'
我试过了
this
没有任何运气。
此外,如果你知道有任何项目使用rspec对这类事情进行测试,那将是非常棒的,文档没有说太多。
更新:
现在它正在运行
active_admin
测试后初始化:
加载时出错
NameError:
uninitialized constant Admin
# ./spec/admin/inactive_user_controller_spec.rb:3:in `<top (required)>'
[3, 12] in /Users/lucia/Documents/frogs-api-remote/config/initializers/active_admin.rb
3: # == Site Title
4: #
5: # Set the title that is displayed on the main layout
6: # for each of the active admin pages.
7: #
=> 8: config.site_title = "Frogs App"
9:
10: # Set the link url for the title. For example, to take
11: # users to your main site. Defaults to no link.
12: #