<commit_before>require 'rails_helper'

RSpec.feature 'Items Index' do
  scenario 'visitor visits the items index page' do
    item_1 = create(:item)
    item_2 = create(:item)
    # Our factories will have to create unique items with a sequence

    visit items_path
    expect(page).to have_content(item_1.title)
    expect(page).to have_content(item_1.description)
    expect(page).to have_content(item_1.price)
    # For now, the image is untested.
    expect(page).to have_content(item_2.title)
    expect(page).to have_content(item_2.description)
    expect(page).to have_content(item_2.price)
  end

  scenario 'visitor clicks on an item and sees individual item page' do
    item1 = create(:item)

    visit items_path
    expect(page).to have_content(item1.title)
    click_on(item1.title)
    expect(page).to have_current_path(category_item_path(item1.category, item1))
    expect(page).to have_content(item1.title)
    expect(page).to have_content(item1.description)
    expect(page).to have_content(item1.price)
  end

  scenario 'visitor clicks on an item and then clicks on category and sees category page' do
    item1 = create(:item)

    visit items_path
    expect(page).to have_content(item1.title)
    click_on(item1.title)
    expect(page).to have_current_path(category_item_path(item1.category, item1))
    click_on(item1.category.title)
    expect(page).to have_current_path(category_path(item1.category))
    expect(page).to have_content("#{item1.category.title} category")
    expect(page).to have_title("Little Shop | #{item1.category.title}")
  end
end<commit_msg>fix test in visitor vists items index<commit_after>require 'rails_helper'

RSpec.feature 'Items Index' do
  scenario 'visitor visits the items index page' do
    item1 = create(:item)
    item2 = create(:item)

    visit items_path

    expect(page).to have_content(item1.title)
    expect(page).to have_content(item1.description)
    expect(page).to have_content(item1.price)
    expect(page).to have_content(item2.title)
    expect(page).to have_content(item2.description)
    expect(page).to have_content(item2.price)
  end

  scenario 'visitor clicks on an item and sees individual item page' do
    item1 = create(:item)

    visit items_path
    click_on(item1.title)

    expect(page).to have_current_path(category_item_path(item1.category, item1))
    expect(page).to have_content(item1.title)
    expect(page).to have_content(item1.description)
    expect(page).to have_content(item1.price)
  end

  scenario 'visitor clicks on an item and then clicks on category and sees category page' do
    item1 = create(:item)

    visit(category_item_path(item1.category, item1))
    within(".main-view") do
      click_on(item1.category.title)
    end

    expect(page).to have_current_path(category_path(item1.category))
    expect(page).to have_content("#{item1.category.title} category")
    expect(page).to have_title("Little Shop | #{item1.category.title}")
  end
end
{'fraction_non_alphanumeric': 0.10327370907863652, 'fraction_numerical': 0.015862301721228485, 'mean_word_length': 4.359855334538879, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6198455', 'n_tokens_mistral': 962, 'n_tokens_neox': 945, 'n_words': 217}