Search code examples
ruby-on-rails-4rspecrubygemsactiveadminrspec-rails

Rspec test if a new action is removed in activeadmin


How to test if new action is removed from ActiveAdmin by Rspec test? If it is passed in the url like /properties/new it will throw an error. I've removed the action.

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

It returns

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

Solution

  • You can use be_routable rspec matcher to verify the route

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