前提・実現したいこと
タイトルのとおりです。
solidusで開発をしており、rspecでテストしていたところ、以下のようなエラーが出ました
発生している問題・エラーメッセージ
1) Potepan::Categories 商品の情報が表示されること Failure/Error: product.master.images.create(attachment: create(:image).attachment.url) Paperclip::AdapterRegistry::NoHandlerError: No handler found for "/spree/products/80/product/thinking-cat.jpg?1629546919" # ./spec/features/potepan/categories_spec.rb:8:in `block (2 levels) in <top (required)>' # ./spec/features/potepan/categories_spec.rb:24:in `block (3 levels) in <top (required)>' # ./spec/features/potepan/categories_spec.rb:21:in `block (2 levels) in <top (required)>' Finished in 35.65 seconds (files took 29.49 seconds to load) 4 examples, 1 failure
該当のソースコード
categories_spec.rb require 'rails_helper' RSpec.feature "Potepan::Categories", type: :feature do given!(:taxonomy) { create(:taxonomy, name: "categories") } given!(:taxon) { taxonomy.root } given!(:product) { create(:product, name: "Bags", taxons: [taxon]) } given(:product_image) do product.master.images.create(attachment: create(:image).attachment.url) ⇦ この部分 end background do visit potepan_category_path(taxon.id) end scenario 'タイトルがカテゴリー名になっていること' do expect(page).to have_title "#{taxon.name} - BIGBAG Store" end scenario '商品の情報が表示されること' do within '.taxon_product_box' do expect(page).to have_content product.name expect(page).to have_content product.display_price expect(page).to have_selector product_image end end scenario 'CategoriesまたはBrandをクリックしたらカテゴリー一覧が表示されること' do within '.category_nav' do find('.collapse_toggle').click taxon.leaves.each do |category| expext(page).to have_content category.id expext(page).to have_content category.name expext(page).to have_content category.products.count end end end scenario '商品をクリックしたら商品詳細ページへ移動すること' do click_on product.name visit potepan_product_path(product.id) end end
_grid_show.html.erb <div class="row taxon_product_box"> <% taxon_product.each do |product| %> <div class="col-sm-4 col-xs-12"> <div class="productBox"> <%= link_to potepan_product_path(product.id) do %> <div class="productImage clearfix"> <%= image_tag(product.display_image.attachment.url, :alt => "products-img") %> </div> <div class="productCaption clearfix"> <h5><%= product.name %></h5> <h3><%= product.display_price %></h3> </div> <% end %> </div> </div> <%= render 'layouts/shared/modal' %> <% end %> </div>
試したこと
・multipart: trueをビューとrspecで試しましたが、同じエラーしか出ません(form_tagは無いので、ダメもとでeach文で試しました)。
・paperclip.rbを作成しPaperclip::DataUriAdapter.registerをしてみましたが、結果は同じでした。
あなたの回答
tips
プレビュー