RailsによるアジャイルWebアプリケーション開発

第11章

タスクFのテスト追加。
画像クリックでカートに追加されるテスト。
sc_pathはパス作成のショートカットメソッド
sleepはanimate用に2と長めにとった。
こういう場合のhave_contentはどこまでやるべき?

require 'rails_helper'

feature "Store", js: true do
  # :
  feature "カート" do
    background do
      @product = create(:product)
      visit store_path
    end

    scenario "画像クリックでカートに対象商品が入ること" do
      find(".entry img").click
      sleep 2

      expect(find("#current_item")).to have_content /1\s+×/
      expect(find("#current_item")).to have_content @product.title
      expect(find("#current_item")).to have_content @product.price
      expect(find(".total_cell")).to have_content @product.price
      save_screenshot(sc_path("store_2.png"))
    end
  end
end

f:id:yossk:20150112093849p:plain