Question

I think I might be suffering from tunnel vision because I can't see what other argument is needed on line 22, following my comment.

    require 'test_helper'

    class RecipesControllerTest < ActionController::TestCase
      setup do
        @recipe = recipes(:one)
        login_as(:one)
      end

      test "should get index" do
        get :index
        assert_response :success
        assert_not_nil assigns(:recipes)
      end

      test "should get new" do
        get :new
        assert_response :success
      end

      test "should create recipe" do

        # it's complaining about this test
        test "should show recipe" do
          get :show, id: @recipe, user_id: @recipe.user_id
          assert_response :success
        end

        test "should get edit" do
          get :edit, id: @recipe
          assert_response :success
        end

        test "should update recipe" do
          patch :update, id: @recipe, recipe: { image_url: @recipe.image_url, instructions: @recipe.instructions, title: @recipe.title, user_id: @recipe.user_id }
          assert_redirected_to recipe_path(assigns(:recipe))
        end

        test "should destroy recipe" do
          assert_difference('Recipe.count', -1) do
            delete :destroy, id: @recipe, user_id: @recipe.user_id
          end

          assert_redirected_to recipes_path
        end
      end
    end

I think the show method only needs the id to locate the recipe. I've tried including

user_id: @recipe.user_id

but I still get the same only 1 argument for 2 error message.

Please note: This is one of my first Rails projects, aka, I'm an extreme noob here. I welcome all constructive criticism about anything you see. Thanks!

Was it helpful?

Solution

Why do you have a test block inside a test block?

test "should create recipe" do

  # it's complaining about this test
  test "should show recipe" do

Remove the outer test "should create recipe" do and add it at the same level as test "should show recipe" do

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top