require "rails_helper"

RSpec.describe "Creating a notebook" do
  let(:user) { create(:user) }

  context "signing in" do
    before do
      sign_in_as user
    end

    describe "creating a notebook" do
      before do
        click_on "Create notebook"

        fill_in "Name", with: "Credit Card"
        fill_in "Description", with: "credit card budget"
        click_on "Save"
      end

      it "shows it on the dashboard page" do
        within("#notebooks") do
          expect(page).to have_content "Credit Card"
          expect(page).to have_content "credit card budget"
        end
      end
    end
  end
end

require "rails_helper"

RSpec.describe "Creating a notebook" do
  let(:user) { create(:user) }

  describe "displaying notebooks" do
    before do
      @some_user = create(:user)
      @not_your_notebook = create(:notebook, name: "Not your notebook", user: @some_user)
      @your_notebook = create(:notebook, name: "Your notebook", user: user)

      sign_in_as user
    end

    it "does not show notebooks you did not created" do
      within("#notebooks") do
        expect(page).to have_content "Your notebook"
        expect(page).not_to have_content "Not your notebook"
      end
    end
  end

  describe "creating a notebook" do
    before do
      sign_in_as user

      click_on "Create notebook"
      fill_in "Name", with: "Credit Card"
      fill_in "Description", with: "credit card budget"
      click_on "Save"
    end

    it "shows it on the dashboard page" do
      within("#notebooks") do
        expect(page).to have_content "Credit Card"
        expect(page).to have_content "credit card budget"
      end
    end

    it "shows a successful message" do
      expect(page).to have_content "Notebook created"
    end
  end
end

Add test scenarios for displaying notebooks per user
Add test scenarios for displaying notebooks per user
