generated from lighthouse-labs/jungle-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created test for adding products to cart
- Loading branch information
1 parent
7a4c678
commit e53702a
Showing
3 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.feature "Item is added to cart", type: :feature, js: true do | ||
|
||
# SETUP | ||
before :each do | ||
# create the category in our database | ||
@category = Category.create! name: 'Apparel' | ||
|
||
# creates the product in our database | ||
@category.products.create!( | ||
name: "Men's T-Shirt", | ||
description: "This is a men's t-shirt, for everyone", | ||
image: open_asset('apparel1.jpg'), | ||
quantity: 10, | ||
price: 64.99 | ||
) | ||
end | ||
|
||
scenario "They see all products on the homepage" do | ||
# This is the homepage | ||
visit root_path | ||
|
||
# The cart should start as empty | ||
expect(page).to have_content "My Cart (0)", count: 1 | ||
# save_and_open_screenshot | ||
|
||
|
||
# clicks 'add' to add the product to the cart | ||
click_button 'Add' | ||
|
||
# expects product page to display when clicked | ||
expect(page).to have_content "My Cart (1)", count: 1 | ||
# save_and_open_screenshot | ||
end | ||
|
||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.feature "Visitor navigates to the product page", type: :feature, js: true do | ||
|
||
# SETUP | ||
before :each do | ||
# create the category in our database | ||
@category = Category.create! name: 'Apparel' | ||
|
||
# creates the product in our database | ||
@category.products.create!( | ||
name: "Men's T-Shirt", | ||
description: "This is a men's t-shirt, for everyone", | ||
image: open_asset('apparel1.jpg'), | ||
quantity: 10, | ||
price: 64.99 | ||
) | ||
end | ||
|
||
scenario "They see all products on the homepage" do | ||
# This is the act | ||
visit root_path | ||
|
||
click_link 'Details' | ||
|
||
# expects product page to display when clicked | ||
expect(page).to have_content "Apparel » Men's T-Shirt", count: 1 | ||
|
||
|
||
# Takes a screenshot | ||
# save_and_open_screenshot | ||
end | ||
|
||
|
||
end |