【问题标题】:Rspec test if a new action is removed in activeadminRspec 测试是否在 activeadmin 中删除了新操作
【发布时间】:2021-03-15 05:20:21
【问题描述】:

如何通过 Rspec 测试测试是否从 ActiveAdmin 中删除了新操作?如果它在像 /properties/new 这样的 url 中传递,它将引发错误。我已删除该操作。

describe "GET new" do
    it "should raise an error" do
      get :new
    end
  end

返回

ActionController::UrlGenerationError:
       No route matches {:action=>"new", :controller=>"admin/properties"}

【问题讨论】:

    标签: ruby-on-rails-4 rspec rubygems activeadmin rspec-rails


    【解决方案1】:

    你可以使用be_routable rspec matcher来验证路由

      describe "GET new" do
        it "not to be routable" do
          expect(get: :new).not_to be_routable
        end
      end
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多