products_test.rb 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. require "application_system_test_case"
  2. class ProductsTest < ApplicationSystemTestCase
  3. setup do
  4. @product = products(:one)
  5. end
  6. test "visiting the index" do
  7. visit products_url
  8. assert_selector "h1", text: "Products"
  9. end
  10. test "should create product" do
  11. visit products_url
  12. click_on "New product"
  13. fill_in "Description", with: @product.description
  14. fill_in "Price", with: @product.price
  15. fill_in "Title", with: @product.title
  16. click_on "Create Product"
  17. assert_text "Product was successfully created"
  18. click_on "Back"
  19. end
  20. test "should update Product" do
  21. visit product_url(@product)
  22. click_on "Edit this product", match: :first
  23. fill_in "Description", with: @product.description
  24. fill_in "Price", with: @product.price
  25. fill_in "Title", with: @product.title
  26. click_on "Update Product"
  27. assert_text "Product was successfully updated"
  28. click_on "Back"
  29. end
  30. test "should destroy Product" do
  31. visit product_url(@product)
  32. accept_confirm { click_on "Destroy this product", match: :first }
  33. assert_text "Product was successfully destroyed"
  34. end
  35. end