title: ActionController::UrlGenerationError, No route matches
body: <p>I've read through every similar question I could find and still can't figure out my problem.</p>
  
  <pre><code># routes.rb
  Rails.application.routes.draw do
    resources :lists, only: [:index, :show, :create, :update, :destroy] do
      resources :items, except: [:new]
    end
  end
  </code></pre>
  
  <hr>
  
  <pre><code># items_controller.rb (excerpt)
  class ItemsController &lt; ApplicationController
    ...
  
    def create
      @list = List.find(params[:list_id])
      ...
    end
    ...
  end
  </code></pre>
  
  <hr>
  
  <pre><code># items_controller_spec.rb (excerpt)
  RSpec.describe ItemsController, type: :controller do
     ...
  
    let!(:list) { List.create(title: "New List title") }
  
    let(:valid_item_attributes) {
      { title: "Some Item Title", complete: false, list_id: list.id }
    }
  
    let!(:item) { list.items.create(valid_item_attributes) }
    describe "POST #create" do
      context "with valid params" do
        it "creates a new item" do
          expect {
            post :create, { item: valid_item_attributes, format: :json  }
          }.to change(Item, :count).by(1)
        end
      end
    end
    ...
  end
  </code></pre>
  
  <p>And the RSpec error:</p>
  
  <pre><code>1) ItemsController POST #create with valid params creates a new item
       Failure/Error: post :create, { item: valid_item_attributes, format: :json  }
       ActionController::UrlGenerationError:
         No route matches {:action=&gt;"create", :controller=&gt;"items", :format=&gt;:json, :item=&gt;{:title=&gt;"Some Item Title", :complete=&gt;false, :list_id=&gt;1}}
  </code></pre>
  
  <p>The output from <code>rake routes</code>:</p>
  
  <pre><code>list_items     GET    /lists/:list_id/items(.:format)          items#index
                 POST   /lists/:list_id/items(.:format)          items#create
  edit_list_item GET    /lists/:list_id/items/:id/edit(.:format) items#edit
       list_item GET    /lists/:list_id/items/:id(.:format)      items#show
                 PATCH  /lists/:list_id/items/:id(.:format)      items#update
                 PUT    /lists/:list_id/items/:id(.:format)      items#update
                 DELETE /lists/:list_id/items/:id(.:format)      items#destroy
  </code></pre>
  
  <p>I can successfully create a new item in an existing list via <code>curl</code> which tells me that the route is ok, I must be doing something wrong in my test.</p>
  
  <pre><code>curl -i -X POST -H "Content-Type:application/json" -H "X-User-Email:admin@example.com" -H "X-Auth-xxx" -d '{ "item": { "title": "new item", "complete": "false"} }' http://localhost:3000/lists/5/items
  </code></pre>
  
  <p>I am really confused. My routes are setup correctly. A <code>ItemsController#create</code> method definitely exists. The rest of the tests in <code>items_controller_spec.rb</code> pass without issue.</p>
  
  <p>Am I missing something obvious?</p>