使用 RSpec 测试您的 ActiveAdmin 资源

Testing your ActiveAdmin resources with RSpec

我是 Rails 的新手。我想测试下面提到的我的 activeadmin 资源 link

https://github.com/activeadmin/activeadmin/wiki/Testing-your-ActiveAdmin-controllers-with-RSpec

我的简单测试如下

require 'spec_helper'

describe "activeadmin resources" do

  it "should have admin user resource" do

    ActiveAdmin.application.namespaces[:admin].resources.should have_key("AdminUser")

  end

end

但我收到错误

NameError: uninitialized constant ActiveAdmin`

我试图在 spec_helper 中要求 activeadmin gem,但没有用。有什么想法吗?

只需更改

require 'spec_helper'

require 'rails_helper'

错误已解决。