Commit c369ecbf by Aman Sharma

Added test cases on model recipe with factories

parent fa5c1a37
......@@ -54,6 +54,7 @@ end
group :test do
gem 'factory_bot_rails'
gem 'faker'
gem 'capybara'
end
......
......@@ -42,12 +42,22 @@ GEM
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
arel (9.0.0)
bindex (0.8.1)
bootsnap (1.4.8)
msgpack (~> 1.0)
builder (3.2.4)
byebug (11.0.1)
capybara (3.15.1)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (~> 1.2)
xpath (~> 3.2)
concurrent-ruby (1.1.7)
crass (1.0.6)
diff-lcs (1.4.4)
......@@ -88,6 +98,7 @@ GEM
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
pg (1.2.3)
public_suffix (4.0.6)
puma (3.12.6)
rack (2.2.3)
rack-proxy (0.6.5)
......@@ -122,6 +133,7 @@ GEM
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
regexp_parser (1.8.1)
rspec-core (3.9.2)
rspec-support (~> 3.9.3)
rspec-expectations (3.9.2)
......@@ -185,6 +197,8 @@ GEM
websocket-driver (0.7.3)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
PLATFORMS
ruby
......@@ -192,6 +206,7 @@ PLATFORMS
DEPENDENCIES
bootsnap (>= 1.1.0)
byebug
capybara
factory_bot_rails
faker
jbuilder (~> 2.5)
......
FactoryBot.define do
factory :random_recipe, class: Recipe do
name { Faker::Food.dish }
ingredients { Faker::Food.ingredient }
instruction { Faker::Food.description }
end
end
require 'rails_helper'
RSpec.describe Recipe do
RSpec.describe Recipe, type: :model do
it 'should run the first test case' do
puts 'hello world! test'
expect('result').to eq('result')
end
describe 'Recipe Model Validation Tests' do
it 'should run the first test case' do
puts 'hello world! test'
expect('result').to eq('result')
end
let(:recipe) { build(:random_recipe) }
it 'should validate the data if name is nil' do
recipe.name = nil
expect(recipe.save).to eq(false)
end
it 'should validate the data if ingredients is nil' do
recipe.ingredients = nil
expect(recipe.save).to eq(false)
end
it 'should validate the data if instruction is nil' do
recipe.instruction = nil
expect(recipe.save).to eq(false)
end
end
end
\ No newline at end of file
RSpec.configure do |config|
config.include FactoryBot::Syntax::Methods
end
\ No newline at end of file
config.include FactoryBot::Syntax::Methods
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment