diff --git a/Gemfile b/Gemfile index c9c002e..2e64451 100644 --- a/Gemfile +++ b/Gemfile @@ -74,8 +74,7 @@ group :test do # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] gem 'capybara' gem 'rspec-rails' - gem 'rails-controller-testing' gem 'selenium-webdriver' - gem 'webdrivers' gem 'shoulda-matchers' + gem 'webdrivers' end diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 96a6e54..2681b23 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -18,10 +18,11 @@ body { font: 500 0.8em "Lato", sans-serif; text-align: center; } + /* Updated CSS for the nav */ .sign_in_user_bar { - margin-top: 0; /* Add this to remove any top margin */ - padding-top: 0; /* Add this to remove any top padding */ + margin-top: 0; + padding-top: 0; background: #2d2738; opacity: 0.95; } @@ -41,6 +42,7 @@ body { width: 70%; margin: 0 auto; } + ul li { margin: 0; padding: 10px 0 10px 0; @@ -59,6 +61,7 @@ li.active { color: orange; transform: scale(1.1); } + a { background-color: #282928; color: rgb(210, 205, 205); /* Set the link color to white */ @@ -172,6 +175,7 @@ form div { label { width: 20%; } + .cont { margin: 0 auto; max-width: 59rem; @@ -180,6 +184,7 @@ label { background-color: greenyellow; opacity: 0.8; } + .register { background-color: #333; margin: 3em auto; @@ -211,6 +216,7 @@ input[type=checkbox] { opacity: 0.8; border-radius: 0.5rem; } + .links { display: flex; gap: 1em; @@ -232,40 +238,12 @@ input[type=checkbox] { opacity: 0.8; } - -/* .container { - max-width: 800px; - margin: 0 auto; - padding: 20px; - background-color: #fff; - border-radius: 5px; - box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); -} */ - -/* h1 { - text-align: center; - margin-top: 20px; -} */ - header { background-color: #333; color: #fff; padding: 10px 0; } -/* nav ul { - list-style: none; -} - -nav ul li { - display: inline; - margin-right: 20px; -} - -nav ul li:last-child { - margin-right: 0; -} */ - .notice { background-color: #4caf50; color: aliceblue; @@ -274,7 +252,7 @@ nav ul li:last-child { max-width: 8em; position: fixed; bottom: 0; - right: 2.5em; + right: 2.5em; } .alert { @@ -285,7 +263,7 @@ nav ul li:last-child { max-width: 8em; position: fixed; bottom: 0; - right: 1em; + right: 1em; } footer { @@ -307,121 +285,82 @@ footer { opacity: 0.8; gap: 5em; } -.recipe{ + +.recipe { display: flex; background-color: rgb(109 111 107); opacity: 0.8; color: #fcfcfc; font-size: medium; } -.recipe p{ + +.recipe p { width: 85%; } -.recipe div{ + +.recipe div { display: flex; flex-direction: column; gap: 1em; } -.total_info{ + +.total_info { display: flex; gap: 1em; justify-content: center; } -#shopping{ + +#shopping { display: flex; flex-direction: column; gap: 1em; font-size: medium; } -.recipe_name a{ + +.recipe_name a { font-size: larger; color: #ef005c; - padding: 0; border-radius: 0%; padding: 0.5em; background-color: rgb(237 242 231); } -.Delete button { - color: white; - background-color: #17141d; - opacity: 0.8; - border-radius: 0.5rem; -} + .field { margin-bottom: 20px; } + #is_public { justify-content: flex-end; display: flex; color: white; } -#is_public button{ - background-color: #2d2e2d; - color: white; -} -#is_public button:hover{ - background-color: rgb(231, 103, 103); -} -.detailsDiv{ - flex-direction: column; - display: flex; - margin: 0 auto; - max-width: 59rem; - padding: 1em; - color: rgb(34, 32, 32); - background-color: greenyellow; - opacity: 0.8; -} -.recipe-food-actions a, .recipe-food-actions button{ +.recipe-food-actions a, +.recipe-food-actions button { display: inline-block; - padding: 1em; - box-shadow: 0 103px 100px rgb(252 251 251 / 20%); + padding: 1em; + box-shadow: 0 103px 100px rgb(252 251 251 / 20%); } - - -/* label { - font-weight: bold; - display: block; -} */ - -/* input[type="text"], -input[type="number"], -textarea { - width: 100%; - padding: 10px; - border: 1px solid #ccc; - border-radius: 5px; -} */ -/* .checkbox { - display: inline; - margin-right: 10px; +#is_public button { + background-color: #2d2e2d; + color: white; } -.actions { - margin-top: 20px; -} */ - -/* button, -input[type="submit"] { - background-color: #333; - color: #fff; - padding: 10px 20px; - border: none; - border-radius: 5px; - cursor: pointer; +#is_public button:hover { + background-color: rgb(231, 103, 103); } -button:hover, -input[type="submit"]:hover { - background-color: #555; */ -/* } - -.buttons { - text-align: right; - margin-top: 20px; -} */ +.detailsDiv { + flex-direction: column; + display: flex; + margin: 0 auto; + max-width: 59rem; + padding: 1em; + color: rgb(34, 32, 32); + background-color: greenyellow; + opacity: 0.8; +} .toggle-button { padding: 10px 20px; @@ -452,6 +391,7 @@ input[type="submit"]:hover { justify-content: space-between; flex-direction: column; } + .btn { display: inline-block; margin-right: 10px; @@ -492,9 +432,11 @@ input[type="submit"]:hover { .item-info { display: flex; } -#recipe_id{ - justify-content:space-around; + +#recipe_id { + justify-content: space-around; } + small { color: black; display: flex; diff --git a/app/controllers/foods_controller.rb b/app/controllers/foods_controller.rb index cf8ec2d..672397f 100644 --- a/app/controllers/foods_controller.rb +++ b/app/controllers/foods_controller.rb @@ -29,30 +29,30 @@ def destroy end def general_shopping_list - @recipes = Recipe.where(user: current_user) - @general_food_list = Food.where(user: current_user) - @missing_food_items = [] - - @recipes.each do |recipe| - recipe.recipe_foods.each do |recipe_food| - general_food = @general_food_list.find_by(id: recipe_food.food_id) - - if general_food.nil? || general_food.quantity < recipe_food.quantity - quantity_needed = recipe_food.quantity - (general_food&.quantity || 0) - price = recipe_food.food.price * quantity_needed - - @missing_food_items << { - food_name: recipe_food.food.name, - quantity_needed: quantity_needed, - price: price - } - end - end - end - - @total_food_items = @missing_food_items.sum { |item| item[:quantity_needed] } - @total_price = @missing_food_items.sum { |item| item[:price] } - end + @recipes = Recipe.where(user: current_user) + @general_food_list = Food.where(user: current_user) + @missing_food_items = [] + + @recipes.each do |recipe| + recipe.recipe_foods.each do |recipe_food| + general_food = @general_food_list.find_by(id: recipe_food.food_id) + + next unless general_food.nil? || general_food.quantity < recipe_food.quantity + + quantity_needed = recipe_food.quantity - (general_food&.quantity || 0) + price = recipe_food.food.price * quantity_needed + + @missing_food_items << { + food_name: recipe_food.food.name, + quantity_needed:, + price: + } + end + end + + @total_food_items = @missing_food_items.sum { |item| item[:quantity_needed] } + @total_price = @missing_food_items.sum { |item| item[:price] } + end private diff --git a/app/controllers/recipe_foods_controller.rb b/app/controllers/recipe_foods_controller.rb index 470ec09..1b2200a 100644 --- a/app/controllers/recipe_foods_controller.rb +++ b/app/controllers/recipe_foods_controller.rb @@ -1,5 +1,5 @@ class RecipeFoodsController < ApplicationController - before_action :set_food_recipe, except: [:edit, :destroy] + before_action :set_food_recipe, except: %i[edit destroy] def new @recipe_food = RecipeFood.new end @@ -15,19 +15,19 @@ def create render 'new' end end - def edit @recipe_food = RecipeFood.find(params[:recipe_id]) @recipe = @recipe_food.recipe - if @recipe_food - # The record was found, proceed with rendering the edit view - else - flash[:alert] = 'Recipe food not found' - redirect_to recipe_path(@recipe.id) - end + if @recipe_food + # The record was found, proceed with rendering the edit view + else + flash[:alert] = 'Recipe food not found' + redirect_to recipe_path(@recipe.id) + end end + def update @recipe_food = RecipeFood.find(params[:id]) if @recipe_food.update(update_food_params) @@ -38,9 +38,8 @@ def update end end - def destroy - puts "youu" + puts 'youu' @recipe_food = RecipeFood.find(params[:recipe_id]) @recipe = @recipe_food.recipe @@ -63,9 +62,8 @@ def set_food_recipe def recipe_food_params params.require(:recipe_food).permit(:quantity, :food_id, :recipe_id) end + def update_food_params params.require(:recipe_food).permit(:quantity) end end - - diff --git a/app/controllers/recipes_controller.rb b/app/controllers/recipes_controller.rb index 5526fa1..980126d 100644 --- a/app/controllers/recipes_controller.rb +++ b/app/controllers/recipes_controller.rb @@ -8,11 +8,11 @@ def index end def show - @recipe = Recipe.includes(recipe_foods: :food).find(params[:id]) - @recipe_foods = @recipe.recipe_foods - @user = current_user - @food = Food.new if current_user == @recipe.user - end + @recipe = Recipe.includes(recipe_foods: :food).find(params[:id]) + @recipe_foods = @recipe.recipe_foods + @user = current_user + @food = Food.new if current_user == @recipe.user + end def new @recipe = Recipe.new diff --git a/spec/factories/recipe_foods.rb b/spec/factories/recipe_foods.rb index 41634f0..39b69a1 100644 --- a/spec/factories/recipe_foods.rb +++ b/spec/factories/recipe_foods.rb @@ -1,10 +1,9 @@ FactoryBot.define do - factory :recipe_food do - # Add attributes for recipe_food here - # For example: - association :recipe - association :food - quantity { 1 } - end + factory :recipe_food do + # Add attributes for recipe_food here + # For example: + association :recipe + association :food + quantity { 1 } end - \ No newline at end of file +end diff --git a/spec/factories/recipes.rb b/spec/factories/recipes.rb index 6d9ca22..4c0b6be 100644 --- a/spec/factories/recipes.rb +++ b/spec/factories/recipes.rb @@ -1,7 +1,7 @@ FactoryBot.define do factory :recipe do - name { "Delicious Recipe" } - description { "This is a tasty recipe." } + name { 'Delicious Recipe' } + description { 'This is a tasty recipe.' } user end -end \ No newline at end of file +end diff --git a/spec/factories/users.rb b/spec/factories/users.rb index bde9bbf..d493aec 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -1,7 +1,7 @@ FactoryBot.define do factory :user do - name { "John Doe" } - email { "john@example.com" } - password { "password123" } + name { 'John Doe' } + email { 'john@example.com' } + password { 'password123' } end -end \ No newline at end of file +end diff --git a/spec/models/food_spec.rb b/spec/models/food_spec.rb index fd4f670..ad92203 100644 --- a/spec/models/food_spec.rb +++ b/spec/models/food_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Food, type: :model do let(:user) { User.create(name: 'John Doe') } - let(:food) { Food.create(user: user, measurement_unit: 'gram', price: 1.2, quantity: 1) } + let(:food) { Food.create(user:, measurement_unit: 'gram', price: 1.2, quantity: 1) } describe 'associations' do it 'belongs to user' do @@ -19,27 +19,26 @@ end end describe 'validation' do - it 'name should be present' do - food.name = nil - expect(food).not_to be_valid - end - it 'is not valid with a negative price' do - food.price = -1 - expect(food).not_to be_valid - end - it 'is not valid with a negative quantity' do - food.quantity = -1 - expect(food).not_to be_valid - end - - it 'price should be valid numericality' do - food.price = 'not_an_integer' - expect(food).not_to be_valid - end - it 'quantity should be valid numericality' do - food.quantity = 'not_an_integer' - expect(food).not_to be_valid - end + it 'name should be present' do + food.name = nil + expect(food).not_to be_valid + end + it 'is not valid with a negative price' do + food.price = -1 + expect(food).not_to be_valid + end + it 'is not valid with a negative quantity' do + food.quantity = -1 + expect(food).not_to be_valid + end + it 'price should be valid numericality' do + food.price = 'not_an_integer' + expect(food).not_to be_valid + end + it 'quantity should be valid numericality' do + food.quantity = 'not_an_integer' + expect(food).not_to be_valid + end + end end -end \ No newline at end of file diff --git a/spec/models/recipe_food_spec.rb b/spec/models/recipe_food_spec.rb index b7d7648..9ab0d13 100644 --- a/spec/models/recipe_food_spec.rb +++ b/spec/models/recipe_food_spec.rb @@ -2,8 +2,8 @@ RSpec.describe RecipeFood, type: :model do let(:user) { User.create(name: 'John Doe') } - let(:recipe) { Recipe.create(user: user, preparation_time: 1, cooking_time: 1, description: 'blabla', public: true) } - let(:food) { Food.create(user: user, measurement_unit: 'gram', price: 1.2, quantity: 1) } + let(:recipe) { Recipe.create(user:, preparation_time: 1, cooking_time: 1, description: 'blabla', public: true) } + let(:food) { Food.create(user:, measurement_unit: 'gram', price: 1.2, quantity: 1) } let!(:recipe_food) { RecipeFood.new(food:, recipe:, quantity: 1) } describe 'associations' do @@ -23,6 +23,6 @@ it 'quantity should be valid numericality' do recipe_food.quantity = 'not_an_integer' expect(food).not_to be_valid - end + end end end diff --git a/spec/models/recipe_model_spec.rb b/spec/models/recipe_model_spec.rb index 41bac67..7a6e382 100644 --- a/spec/models/recipe_model_spec.rb +++ b/spec/models/recipe_model_spec.rb @@ -1,32 +1,32 @@ require 'rails_helper' RSpec.describe Recipe, type: :model do - it "is valid with valid attributes" do + it 'is valid with valid attributes' do recipe = build(:recipe) expect(recipe).to be_valid end - it "is not valid without a name" do + it 'is not valid without a name' do recipe = build(:recipe, name: nil) expect(recipe).not_to be_valid end - it "is not valid without a description" do + it 'is not valid without a description' do recipe = build(:recipe, description: nil) expect(recipe).not_to be_valid end - it "belongs to a user" do + it 'belongs to a user' do association = described_class.reflect_on_association(:user) expect(association.macro).to eq :belongs_to end - it "has many recipe_foods" do + it 'has many recipe_foods' do association = described_class.reflect_on_association(:recipe_foods) expect(association.macro).to eq :has_many end - it "has many foods through recipe_foods" do + it 'has many foods through recipe_foods' do association = described_class.reflect_on_association(:foods) expect(association.macro).to eq :has_many end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 98189c8..80bc5f7 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' RSpec.describe User, type: :model do - it "is valid with valid attributes" do + it 'is valid with valid attributes' do user = User.new( - name: "John Doe", - email: "john@example.com", - password: "password123", - password_confirmation: "password123" + name: 'John Doe', + email: 'john@example.com', + password: 'password123', + password_confirmation: 'password123' ) expect(user).to be_valid end - it "is not valid without a name" do + it 'is not valid without a name' do user = User.new( - email: "john@example.com", - password: "password123", - password_confirmation: "password123" + email: 'john@example.com', + password: 'password123', + password_confirmation: 'password123' ) expect(user).to_not be_valid end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 1daf11e..bf67451 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -3,7 +3,7 @@ ENV['RAILS_ENV'] ||= 'test' require_relative '../config/environment' # Prevent database truncation if the environment is production -abort("The Rails environment is running in production mode!") if Rails.env.production? +abort('The Rails environment is running in production mode!') if Rails.env.production? require 'rspec/rails' # Add additional requires below this line. Rails is not loaded until this point! @@ -31,7 +31,7 @@ end RSpec.configure do |config| # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" + config.fixture_path = "#{Rails.root}/spec/fixtures" # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false diff --git a/spec/requests/foods_spec.rb b/spec/requests/foods_spec.rb index ccb6742..bf2e1a4 100644 --- a/spec/requests/foods_spec.rb +++ b/spec/requests/foods_spec.rb @@ -17,16 +17,16 @@ expect(response).to render_template(:index) end end - + describe 'GET #new' do - it 'returns a successful response' do - get :new - expect(response).to have_http_status(:success) - end + it 'returns a successful response' do + get :new + expect(response).to have_http_status(:success) + end - it 'renders the new template' do - get :new - expect(response).to render_template(:new) + it 'renders the new template' do + get :new + expect(response).to render_template(:new) + end end end -end \ No newline at end of file diff --git a/spec/requests/recipe_foods_spec.rb b/spec/requests/recipe_foods_spec.rb index 59fd470..514d791 100644 --- a/spec/requests/recipe_foods_spec.rb +++ b/spec/requests/recipe_foods_spec.rb @@ -2,10 +2,10 @@ RSpec.describe RecipeFoodsController, type: :controller do let(:user) { FactoryBot.create(:user) } - let(:recipe) { FactoryBot.create(:recipe, user: user) } + let(:recipe) { FactoryBot.create(:recipe, user:) } - describe "GET #new" do - it "returns a successful response" do + describe 'GET #new' do + it 'returns a successful response' do get :new, params: { recipe_id: recipe.id } expect(response).to be_successful end diff --git a/spec/requests/users_spec.rb b/spec/requests/users_spec.rb index 98189c8..80bc5f7 100644 --- a/spec/requests/users_spec.rb +++ b/spec/requests/users_spec.rb @@ -1,21 +1,21 @@ require 'rails_helper' RSpec.describe User, type: :model do - it "is valid with valid attributes" do + it 'is valid with valid attributes' do user = User.new( - name: "John Doe", - email: "john@example.com", - password: "password123", - password_confirmation: "password123" + name: 'John Doe', + email: 'john@example.com', + password: 'password123', + password_confirmation: 'password123' ) expect(user).to be_valid end - it "is not valid without a name" do + it 'is not valid without a name' do user = User.new( - email: "john@example.com", - password: "password123", - password_confirmation: "password123" + email: 'john@example.com', + password: 'password123', + password_confirmation: 'password123' ) expect(user).to_not be_valid end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 327b58e..9c96a9b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -44,51 +44,49 @@ # triggering implicit auto-inclusion in groups with matching metadata. config.shared_context_metadata_behavior = :apply_to_host_groups -# The settings below are suggested to provide a good initial experience -# with RSpec, but feel free to customize to your heart's content. -=begin - # This allows you to limit a spec run to individual examples or groups - # you care about by tagging them with `:focus` metadata. When nothing - # is tagged with `:focus`, all examples get run. RSpec also provides - # aliases for `it`, `describe`, and `context` that include `:focus` - # metadata: `fit`, `fdescribe` and `fcontext`, respectively. - config.filter_run_when_matching :focus - - # Allows RSpec to persist some state between runs in order to support - # the `--only-failures` and `--next-failure` CLI options. We recommend - # you configure your source control system to ignore this file. - config.example_status_persistence_file_path = "spec/examples.txt" - - # Limits the available syntax to the non-monkey patched syntax that is - # recommended. For more details, see: - # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/ - config.disable_monkey_patching! - - # Many RSpec users commonly either run the entire suite or an individual - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = "doc" - end - - # Print the 10 slowest examples and example groups at the - # end of the spec run, to help surface which specs are running - # particularly slow. - config.profile_examples = 10 - - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = :random - - # Seed global randomization in this process using the `--seed` CLI option. - # Setting this allows you to use `--seed` to deterministically reproduce - # test failures related to randomization by passing the same `--seed` value - # as the one that triggered the failure. - Kernel.srand config.seed -=end + # The settings below are suggested to provide a good initial experience + # with RSpec, but feel free to customize to your heart's content. + # # This allows you to limit a spec run to individual examples or groups + # # you care about by tagging them with `:focus` metadata. When nothing + # # is tagged with `:focus`, all examples get run. RSpec also provides + # # aliases for `it`, `describe`, and `context` that include `:focus` + # # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + # config.filter_run_when_matching :focus + # + # # Allows RSpec to persist some state between runs in order to support + # # the `--only-failures` and `--next-failure` CLI options. We recommend + # # you configure your source control system to ignore this file. + # config.example_status_persistence_file_path = "spec/examples.txt" + # + # # Limits the available syntax to the non-monkey patched syntax that is + # # recommended. For more details, see: + # # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/ + # config.disable_monkey_patching! + # + # # Many RSpec users commonly either run the entire suite or an individual + # # file, and it's useful to allow more verbose output when running an + # # individual spec file. + # if config.files_to_run.one? + # # Use the documentation formatter for detailed output, + # # unless a formatter has already been configured + # # (e.g. via a command-line flag). + # config.default_formatter = "doc" + # end + # + # # Print the 10 slowest examples and example groups at the + # # end of the spec run, to help surface which specs are running + # # particularly slow. + # config.profile_examples = 10 + # + # # Run specs in random order to surface order dependencies. If you find an + # # order dependency and want to debug it, you can fix the order by providing + # # the seed, which is printed after each run. + # # --seed 1234 + # config.order = :random + # + # # Seed global randomization in this process using the `--seed` CLI option. + # # Setting this allows you to use `--seed` to deterministically reproduce + # # test failures related to randomization by passing the same `--seed` value + # # as the one that triggered the failure. + # Kernel.srand config.seed end diff --git a/spec/views/food_index_spec.rb b/spec/views/food_index_spec.rb index ea5ce61..96a1e44 100644 --- a/spec/views/food_index_spec.rb +++ b/spec/views/food_index_spec.rb @@ -1,16 +1,15 @@ require 'rails_helper' -RSpec.feature "Food Index", type: :feature do +RSpec.feature 'Food Index', type: :feature do let(:user) { FactoryBot.create(:user) } - scenario "User views the list of available foods" do - + scenario 'User views the list of available foods' do visit foods_path end - scenario "User views a message when there are no available foods" do + scenario 'User views a message when there are no available foods' do visit foods_path - expect(page).not_to have_table("food-table") + expect(page).not_to have_table('food-table') end end diff --git a/spec/views/general_shopping_list_spec.rb b/spec/views/general_shopping_list_spec.rb index 6340491..3e16c0f 100644 --- a/spec/views/general_shopping_list_spec.rb +++ b/spec/views/general_shopping_list_spec.rb @@ -2,19 +2,17 @@ require 'rails_helper' -RSpec.feature "General Shopping List", type: :feature do +RSpec.feature 'General Shopping List', type: :feature do let(:user) { FactoryBot.create(:user) } - let(:recipe) { FactoryBot.create(:recipe, user: user) } - - scenario "User views the general shopping list with missing food items" do + let(:recipe) { FactoryBot.create(:recipe, user:) } + scenario 'User views the general shopping list with missing food items' do visit general_shopping_list_path end - scenario "User views the general shopping list with no missing food items" do - + scenario 'User views the general shopping list with no missing food items' do visit general_shopping_list_path - expect(page).not_to have_table("shopping-list-table") + expect(page).not_to have_table('shopping-list-table') end end diff --git a/spec/views/show.html.erb_spec.rb b/spec/views/show.html.erb_spec.rb index 4e42175..42e650b 100644 --- a/spec/views/show.html.erb_spec.rb +++ b/spec/views/show.html.erb_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' -RSpec.describe "recipes/show", type: :view do - let(:user) { FactoryBot.build(:user) } - let(:recipe) { FactoryBot.create(:recipe, user: user) } +RSpec.describe 'recipes/show', type: :view do + let(:user) { FactoryBot.build(:user) } + let(:recipe) { FactoryBot.create(:recipe, user:) } before do assign(:recipe, recipe) @@ -10,19 +10,19 @@ render end - it "displays recipe details" do + it 'displays recipe details' do expect(rendered).to match(/#{recipe.name}/) expect(rendered).to match(/#{recipe.preparation_time}/) expect(rendered).to match(/#{recipe.cooking_time}/) end - it "displays buttons for authorized user" do - expect(rendered).to have_link("Generate shopping list", href: general_shopping_list_path) - expect(rendered).to have_link("Add ingredient", href: new_recipe_recipe_food_path(recipe)) + it 'displays buttons for authorized user' do + expect(rendered).to have_link('Generate shopping list', href: general_shopping_list_path) + expect(rendered).to have_link('Add ingredient', href: new_recipe_recipe_food_path(recipe)) end - it "displays make public/private button for recipe owner" do - expect(rendered).to have_button("Make it Private") if recipe.public? - expect(rendered).to have_button("Make it Public") unless recipe.public? + it 'displays make public/private button for recipe owner' do + expect(rendered).to have_button('Make it Private') if recipe.public? + expect(rendered).to have_button('Make it Public') unless recipe.public? end end