■Background
I'm working on an assignment at a certain school.
There is a time limit, but the school mentor's response is late, so please let me ask you a question.
■What you want to achieve
I want to pass this test code as systemspec
■Current state
Rspec wants to pass, but it doesn't.Let me ask you the following questions.
The following error occurs when running bundle exec rspec:
US>Error Messages
Capybara::ElementNotFound:
Unable to find link
■ What you actually tried
Search by error message and
I tried adding an id to the link with reference to the following, but it failed (and it got worse because I couldn't pass the test I was taking so far).
https://www.halu.dev/entry/2015/11/17/210904
■Other reference images
spec_helper

rails_helper

■ Code
HTML Code
<%provide(:title,@product.name)%>
<div class="main-wrapper">
<section class="lightSection clearfix pageHeader">
<div class="container">
<div class="row">
<div class="col-xs-6">
<div class="page-title">
<h2><%[email protected]%></h2>
</div>
</div>
<div class="col-xs-6">
<ol class="breadcrumb pull-right">
<li><%=link_to 'Home', potpan_path%>/li>
<lic class="active">%[email protected]%>/li>
</ol>
</div>
</div>
</div>
</section>
<section class="mainContent clearfix">
<div class="container">
<div class="row singleProduct">
<div class="col-xs-12">
<div class="media">
<div class="media-left productSlider">
<divid="carousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<%@product.images.each_with_index do | image, i | %>
<div class="item<%="active" if i.zero?%>">
<%=image_tag(image.attachment(:large))%>
</div>
<%end%>
</div>
</div>
<div class="clearfix">
<divid="thumbcarousel" class="carousel slide" data-interval="false">
<div class="carousel-inner">
<%@product.images.each_with_index do | image, i | %>
<div data-target="#carousel"data-slide-to="<%=i%>"class="thumb">
<%=image_tag(image.attachment(:small))%>
</div>
<%end%>
</div>
<a class="left carousel-control" href="#thumbcarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left">/span>
</a>
<a class="right carousel-control" href="#thumbcarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right">/span>
</a>
</div>
</div>
</div>
<div class="media-body">
<ul class="list-inline">
<li>
<%=link_to potapan_category_path(@product.taxons.first.id)do%>
<ic class="fa fa-reply" aria-hidden="true"></i> Back to List Page
<%end%>
</li>
</ul>
<h2><%[email protected]%></h2>
<h3><%[email protected]_price%>/h3>
<p><%[email protected]%>/p>
<span class="quick-drop">
<select name="guiest_id3" id="guest_id3" class="select-drop">
<option value="0">S</option>
<option value="1">M</option>
<option value="2">L</option>
<option value="3">XL</option>
</select>
</span>
<span class="quick-drop resizeWidth">
<select name="guiest_id4" id="guest_id4" class="select-drop">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</span>
<div class="btn-area">
<a href="cart_page.html" class="btn btn-primary btn-block" <i class="fa fa-angle-right" aria-hidden="true" </i><a>
</div>
</div>
</div>
</div>
</div>
rspec Code
require 'rails_helper'
RSpec.describe "Products", type: :system do
include Rails.application.routes.url_helpers
describe "GET #show" do
let(:image) {create(:image)}
let(:product){create(:product,taxons:[taxon])}
let(:taxonomy) {create(:taxonomy)}
let(:taxon) {create(:taxon,taxonomy:taxonomy)}
before do
product.images<<image
get potpan_product_path(product.id)
# Addressing issues where image URL acquisition is not successful
# # https://mng-camp.potepan.com/curriculums/document-for-final-task-2#notes-of-image-test
ActiveStorage:: Current.host=request.base_url
end
"It ""Click ""Back to List Page"" to access the product category page"" do
click_link('my_id')
expect(current_path).to eq potepan_category_path(taxons.id)
end
"it" page must be displayed" do
expect(response).to have_http_status(:success)
end
it "The name of the item must be displayed" do
expect(response.body).to include product.name
end
it "The price of the item must be displayed" do
expect(response.body).to include product.display_price.to_s
end
it "Product description is displayed" do
expect(response.body).to include product.description
end
end
end
Self-resolved.
visit affected path
passed the test in
2935 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
1856 I want to connect to the webcam from WSL(ubuntu)
1858 M2 Mac fails to install rbenv install 3.1.3 due to errors
1699 Error in x, y, and format string must not be None
1721 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2025 OneMinuteCode. All rights reserved.