-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix tests by replacing string Gram with gram(s)
- Loading branch information
Showing
7 changed files
with
26 additions
and
18 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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
class Food < ApplicationRecord | ||
belongs_to :user | ||
validates :name, presence: true | ||
validates :measure_unit, presence: true, inclusion: { in: %w[Gram Pound Unit] } | ||
validates :price, presence: true, numericality: { only_integer: true } | ||
validates :measure_unit, presence: true, inclusion: { in: %w[gram(s) pound(s) unit(s)] } | ||
validates :quantity, presence: true, numericality: { only_integer: true } | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,10 +8,14 @@ | |
created_at: '2023-05-22 16:34:29.347120000 +0000', | ||
updated_at: '2023-05-22 16:34:29.347120000 +0000', | ||
email: '[email protected]', | ||
password: '111111') | ||
password: '111111', | ||
password_confirmation: '111111') | ||
end | ||
let(:f1) { Food.create(name: 'Burger', measure_unit: 'gram(s)', price: 2, quantity: 2, user_id: u1.id) } | ||
before(:each) do | ||
u1.save | ||
f1.save | ||
end | ||
let(:f1) { Food.new(name: 'Burger', measure_unit: 'Gram', price: 2, quantity: 2, user_id: u1.id) } | ||
|
||
it 'should have the correct name' do | ||
expect(f1.name).to eq('Burger') | ||
end | ||
|
@@ -20,7 +24,7 @@ | |
end | ||
|
||
it 'should have the correct measure unit' do | ||
expect(f1.measure_unit).to eq('Gram') | ||
expect(f1.measure_unit).to eq('gram(s)') | ||
end | ||
|
||
it 'should have the correct price' do | ||
|
@@ -45,14 +49,15 @@ | |
created_at: '2023-05-22 16:34:29.347120000 +0000', | ||
updated_at: '2023-05-22 16:34:29.347120000 +0000', | ||
email: '[email protected]', | ||
password: '111111') | ||
password: '111111', | ||
password_confirmation: '111111') | ||
end | ||
let(:f1) { Food.new(name: 'Burger', measure_unit: 'Gram', price: 2, quantity: 2, user_id: u2.id) } | ||
let(:f1) { Food.new(name: 'Burger', measure_unit: 'gram(s)', price: 2, quantity: 2, user_id: u2.id) } | ||
it 'should have name of food' do | ||
expect(f1.name).to eq('Burger') | ||
end | ||
it 'should have measute unit of food' do | ||
expect(f1.measure_unit).to eq('Gram') | ||
expect(f1.measure_unit).to eq('gram(s)') | ||
end | ||
it 'should have price of food' do | ||
expect(f1.price).to eq(2) | ||
|
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 |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
email: '[email protected]', | ||
password: '111111') | ||
end | ||
let(:f1) { Food.new(name: 'Burger', measure_unit: 'Gram', price: 2, quantity: 2, user_id: u1.id) } | ||
let(:f1) { Food.new(name: 'Burger', measure_unit: 'gram(s)', price: 2, quantity: 2, user_id: u1.id) } | ||
let(:r1) do | ||
Recipe.create(id: 12, | ||
name: 'BBQ Burger', | ||
|
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 |
---|---|---|
|
@@ -8,7 +8,8 @@ | |
created_at: '2023-05-22 16:34:29.347120000 +0000', | ||
updated_at: '2023-05-22 16:34:29.347120000 +0000', | ||
email: '[email protected]', | ||
password: '111111') | ||
password: '111111', | ||
password_confirmation: '111111') | ||
end | ||
|
||
it 'should have the correct name' do | ||
|
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 |
---|---|---|
|
@@ -8,9 +8,10 @@ | |
created_at: '2023-05-22 16:34:29.347120000 +0000', | ||
updated_at: '2023-05-22 16:34:29.347120000 +0000', | ||
email: '[email protected]', | ||
password: '111111') | ||
password: '111111', | ||
password_confirmation: '111111') | ||
end | ||
let(:f1) { Food.new(name: 'Burger', measure_unit: 'Gram', price: 2, quantity: 2, user_id: u1.id) } | ||
let(:f1) { Food.new(name: 'Burger', measure_unit: 'gram(s)', price: 2, quantity: 2, user_id: u1.id) } | ||
let(:r1) do | ||
Recipe.create(id: 1, | ||
name: 'BBQ Burger', | ||
|
@@ -45,7 +46,7 @@ | |
expect(page).to have_content('Burger') | ||
expect(page).to have_content('Price: 2') | ||
expect(page).to have_content('Quantity: 2') | ||
expect(page).to have_content('Measure unit: Gram') | ||
expect(page).to have_content('Measure unit: gram(s)') | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,10 +8,11 @@ | |
created_at: '2023-05-22 16:34:29.347120000 +0000', | ||
updated_at: '2023-05-22 16:34:29.347120000 +0000', | ||
email: '[email protected]', | ||
password: '111111') | ||
password: '111111', | ||
password_confirmation: '111111') | ||
end | ||
let(:f1) do | ||
Food.new(name: 'Burger', measure_unit: 'Gram', price: 2, quantity: 2, user_id: u1.id) | ||
Food.new(name: 'Burger', measure_unit: 'gram(s)', price: 2, quantity: 2, user_id: u1.id) | ||
end | ||
let(:r1) do | ||
Recipe.create(id: 12, | ||
|
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 |
---|---|---|
|
@@ -8,9 +8,10 @@ | |
created_at: '2023-05-22 16:34:29.347120000 +0000', | ||
updated_at: '2023-05-22 16:34:29.347120000 +0000', | ||
email: '[email protected]', | ||
password: '111111') | ||
password: '111111', | ||
password_confirmation: '111111') | ||
end | ||
let(:f1) { Food.new(name: 'Burger', measure_unit: 'Gram', price: 2, quantity: 2, user_id: u1.id) } | ||
let(:f1) { Food.new(name: 'Burger', measure_unit: 'gram(s)', price: 2, quantity: 2, user_id: u1.id) } | ||
before(:each) do | ||
f1.save | ||
end | ||
|