title: Uncountable model testing with rspec and capybara
body: <p>I am using rails 5.0.0.1 to build a small inventory type system for some equipment I lone to people.  One of my models is named equipment which of course is an uncountable model (singular and plural of equipment is the same).  When I try to write feature tests for this model I get one of two possible errors when I try to visit the index page.  If I use "visit equipment_url" I am told there is no route for "show" because there is no id.  This is a correct error if I wanted to go to show but I don't.  If I try "visit equipment_index_url" I am told there is no method visit.</p>
  
  <pre><code>Routes
                  Prefix Verb   URI Pattern                             Controller#Action
                    root GET    /                                       inventory#index
        delete_equipment GET    /equipment/:id/delete(.:format)         equipment#delete
                         DELETE /equipment/:id/delete(.:format)         equipment#destroy
         equipment_index GET    /equipment(.:format)                    equipment#index
                         POST   /equipment(.:format)                    equipment#create
           new_equipment GET    /equipment/new(.:format)                equipment#new
          edit_equipment GET    /equipment/:id/edit(.:format)           equipment#edit
               equipment GET    /equipment/:id(.:format)                equipment#show
                         PATCH  /equipment/:id(.:format)                equipment#update
                         PUT    /equipment/:id(.:format)                equipment#update
                         DELETE /equipment/:id(.:format)                equipment#destroy
        delete_specialty GET    /specialties/:id/delete(.:format)       specialties#delete
                         DELETE /specialties/:id/delete(.:format)       specialties#destroy
             specialties GET    /specialties(.:format)                  specialties#index
                         POST   /specialties(.:format)                  specialties#create
           new_specialty GET    /specialties/new(.:format)              specialties#new
          edit_specialty GET    /specialties/:id/edit(.:format)         specialties#edit
               specialty GET    /specialties/:id(.:format)              specialties#show
                         PATCH  /specialties/:id(.:format)              specialties#update
                         PUT    /specialties/:id(.:format)              specialties#update
                         DELETE /specialties/:id(.:format)              specialties#destroy
            delete_event GET    /events/:id/delete(.:format)            events#delete
                         DELETE /events/:id/delete(.:format)            events#destroy
                  events GET    /events(.:format)                       events#index
                         POST   /events(.:format)                       events#create
               new_event GET    /events/new(.:format)                   events#new
              edit_event GET    /events/:id/edit(.:format)              events#edit
                   event GET    /events/:id(.:format)                   events#show
                         PATCH  /events/:id(.:format)                   events#update
                         PUT    /events/:id(.:format)                   events#update
                         DELETE /events/:id(.:format)                   events#destroy
             delete_type GET    /types/:id/delete(.:format)             types#delete
                         DELETE /types/:id/delete(.:format)             types#destroy
                   types GET    /types(.:format)                        types#index
                         POST   /types(.:format)                        types#create
                new_type GET    /types/new(.:format)                    types#new
               edit_type GET    /types/:id/edit(.:format)               types#edit
                    type GET    /types/:id(.:format)                    types#show
                         PATCH  /types/:id(.:format)                    types#update
                         PUT    /types/:id(.:format)                    types#update
                         DELETE /types/:id(.:format)                    types#destroy
  delete_event_specialty GET    /event_specialties/:id/delete(.:format) event_specialties#delete
                         DELETE /event_specialties/:id/delete(.:format) event_specialties#destroy
       event_specialties GET    /event_specialties(.:format)            event_specialties#index
                         POST   /event_specialties(.:format)            event_specialties#create
     new_event_specialty GET    /event_specialties/new(.:format)        event_specialties#new
    edit_event_specialty GET    /event_specialties/:id/edit(.:format)   event_specialties#edit
         event_specialty GET    /event_specialties/:id(.:format)        event_specialties#show
                         PATCH  /event_specialties/:id(.:format)        event_specialties#update
                         PUT    /event_specialties/:id(.:format)        event_specialties#update
                         DELETE /event_specialties/:id(.:format)        event_specialties#destroy
  </code></pre>
  
  <p>spec/features/equipment_spec.rb</p>
  
  <pre><code>require 'rails_helper'
  
  RSpec.describe "Equipment", type: :request do
    describe "GET /equipment" do
      it "Adds a new equipment" do
          @types = FactoryGirl.create_list(:multitype, 25)
          @specialties = FactoryGirl.create_list(:multispecialty, 25)
          visit equipment_index_url
          expect{
              click_link 'New Equipment'
              fill_in "Equipment No", with: "2"
              fill_in "Serial", with: "123456"
              fill_in "Description", with: "Test Equipment"
              select "radio10", from: "equipment_type_id"
              select "tech13", from: "equipment_specialty_id"
              click_button "Create Equipment"
          }.to change(Equipment, :count).by(1)
          expect(page).to have_content("Equipment was successfully created")
      end
  
      it "deletes without javascript" do
          equipment = FactoryGirl.create(:equipment)
          visit equipment_url
          expect {
              click_link "Destroy"
          }.to change(Equipment, :count).by(-1)
          expect(page).to have_content("Equipment was successfully destroyed")
      end
  
      it "edits a equipment" do
          equipment = FactoryGirl.create(:equipment)
          visit equipment_url
          click_link 'Edit'
          fill_in "Serial", with: "456789"
          click_button "Update Equipment"
          expect(page).to have_content("Equipment was successfully updated")
          expect(page).to have_content("Serial: 456789")
      end
  
      it "shows a equipment" do
          equipment = FactoryGirl.create(:equipment)
          visit equipment_url
          click_link 'Show'
          expect(page).to have_content("Serial: rad123")
          expect(page).to have_link("Edit")
          expect(page).to have_link("Back", href: equipment_path)
      end
    end
  end
  </code></pre>
  
  <p>Errors</p>
  
  <pre><code>Equipment
    GET /equipment
      Adds a new equipment (FAILED - 1)
      deletes without javascript (FAILED - 2)
      edits a equipment (FAILED - 3)
      shows a equipment (FAILED - 4)
  </code></pre>
  
  <p>Failures:</p>
  
  <p>1) Equipment GET /equipment Adds a new equipment
       Failure/Error: visit equipment_index_url</p>
  
  <pre><code> NoMethodError:
     undefined method `visit' for #&lt;RSpec::ExampleGroups::Equipment::GETEquipment:0x000000065c32e8&gt;
   # ./spec/features/equipment_spec.rb:8:in `block (3 levels) in &lt;top (required)&gt;'
   # /home/tom/.rvm/gems/ruby-2.3.1@rails5.0/gems/rspec-retry-0.5.2/lib/rspec/retry.rb:112:in `block in run'
   # /home/tom/.rvm/gems/ruby-2.3.1@rails5.0/gems/rspec-retry-0.5.2/lib/rspec/retry.rb:101:in `loop'
   # /home/tom/.rvm/gems/ruby-2.3.1@rails5.0/gems/rspec-retry-0.5.2/lib/rspec/retry.rb:101:in `run'
   # /home/tom/.rvm/gems/ruby-2.3.1@rails5.0/gems/rspec-retry-0.5.2/lib/rspec_ext/rspec_ext.rb:12:in `run_with_retry'
   # /home/tom/.rvm/gems/ruby-2.3.1@rails5.0/gems/rspec-retry-0.5.2/lib/rspec/retry.rb:30:in `block (2 levels) in setup'
  </code></pre>
  
  <p>2) Equipment GET /equipment deletes without javascript
       Failure/Error: visit equipment_url</p>
  
  <pre><code> ActionController::UrlGenerationError:
     No route matches {:action=&gt;"show", :controller=&gt;"equipment"} missing required keys: [:id]
   # ./spec/features/equipment_spec.rb:23:in `block (3 levels) in &lt;top (required)&gt;'
   # /home/tom/.rvm/gems/ruby-2.3.1@rails5.0/gems/rspec-retry-0.5.2/lib/rspec/retry.rb:112:in `block in run'
   # /home/tom/.rvm/gems/ruby-2.3.1@rails5.0/gems/rspec-retry-0.5.2/lib/rspec/retry.rb:101:in `loop'
   # /home/tom/.rvm/gems/ruby-2.3.1@rails5.0/gems/rspec-retry-0.5.2/lib/rspec/retry.rb:101:in `run'
   # /home/tom/.rvm/gems/ruby-2.3.1@rails5.0/gems/rspec-retry-0.5.2/lib/rspec_ext/rspec_ext.rb:12:in `run_with_retry'
   # /home/tom/.rvm/gems/ruby-2.3.1@rails5.0/gems/rspec-retry-0.5.2/lib/rspec/retry.rb:30:in `block (2 levels) in setup'
  </code></pre>
  
  <p>3) Equipment GET /equipment edits a equipment
       Failure/Error: visit equipment_url</p>
  
  <pre><code> ActionController::UrlGenerationError:
     No route matches {:action=&gt;"show", :controller=&gt;"equipment"} missing required keys: [:id]
   # ./spec/features/equipment_spec.rb:32:in `block (3 levels) in &lt;top (required)&gt;'
   # /home/tom/.rvm/gems/ruby-2.3.1@rails5.0/gems/rspec-retry-0.5.2/lib/rspec/retry.rb:112:in `block in run'
   # /home/tom/.rvm/gems/ruby-2.3.1@rails5.0/gems/rspec-retry-0.5.2/lib/rspec/retry.rb:101:in `loop'
   # /home/tom/.rvm/gems/ruby-2.3.1@rails5.0/gems/rspec-retry-0.5.2/lib/rspec/retry.rb:101:in `run'
   # /home/tom/.rvm/gems/ruby-2.3.1@rails5.0/gems/rspec-retry-0.5.2/lib/rspec_ext/rspec_ext.rb:12:in `run_with_retry'
   # /home/tom/.rvm/gems/ruby-2.3.1@rails5.0/gems/rspec-retry-0.5.2/lib/rspec/retry.rb:30:in `block (2 levels) in setup'
  </code></pre>
  
  <p>4) Equipment GET /equipment shows a equipment
       Failure/Error: visit equipment_url</p>
  
  <pre><code> ActionController::UrlGenerationError:
     No route matches {:action=&gt;"show", :controller=&gt;"equipment"} missing required keys: [:id]
   # ./spec/features/equipment_spec.rb:42:in `block (3 levels) in &lt;top (required)&gt;'
   # /home/tom/.rvm/gems/ruby-2.3.1@rails5.0/gems/rspec-retry-0.5.2/lib/rspec/retry.rb:112:in `block in run'
   # /home/tom/.rvm/gems/ruby-2.3.1@rails5.0/gems/rspec-retry-0.5.2/lib/rspec/retry.rb:101:in `loop'
   # /home/tom/.rvm/gems/ruby-2.3.1@rails5.0/gems/rspec-retry-0.5.2/lib/rspec/retry.rb:101:in `run'
   # /home/tom/.rvm/gems/ruby-2.3.1@rails5.0/gems/rspec-retry-0.5.2/lib/rspec_ext/rspec_ext.rb:12:in `run_with_retry'
   # /home/tom/.rvm/gems/ruby-2.3.1@rails5.0/gems/rspec-retry-0.5.2/lib/rspec/retry.rb:30:in `block (2 levels) in setup'
  
  Finished in 0.28107 seconds (files took 2.61 seconds to load)
  4 examples, 4 failures
  </code></pre>
  
  <p>Failed examples:</p>
  
  <pre><code>rspec ./spec/features/equipment_spec.rb:5 # Equipment GET /equipment Adds a new equipment
  rspec ./spec/features/equipment_spec.rb:21 # Equipment GET /equipment deletes without javascript
  rspec ./spec/features/equipment_spec.rb:30 # Equipment GET /equipment edits a equipment
  rspec ./spec/features/equipment_spec.rb:40 # Equipment GET /equipment shows a equipment
  </code></pre>
  
  <p>Any Ideas on how to make it work would be greatly appreciated</p>