Commit 993ccc23 by Vijay Gawariya

Merge branch 'master' of 35.155.93.82:amansharma/react-rails-rspec

parents aadb6ee8 711137cb
...@@ -54,6 +54,7 @@ end ...@@ -54,6 +54,7 @@ end
group :test do group :test do
gem 'factory_bot_rails' gem 'factory_bot_rails'
gem 'faker' gem 'faker'
gem 'capybara'
end end
......
...@@ -42,12 +42,22 @@ GEM ...@@ -42,12 +42,22 @@ GEM
i18n (>= 0.7, < 2) i18n (>= 0.7, < 2)
minitest (~> 5.1) minitest (~> 5.1)
tzinfo (~> 1.1) tzinfo (~> 1.1)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
arel (9.0.0) arel (9.0.0)
bindex (0.8.1) bindex (0.8.1)
bootsnap (1.4.8) bootsnap (1.4.8)
msgpack (~> 1.0) msgpack (~> 1.0)
builder (3.2.4) builder (3.2.4)
byebug (11.0.1) 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) concurrent-ruby (1.1.7)
crass (1.0.6) crass (1.0.6)
diff-lcs (1.4.4) diff-lcs (1.4.4)
...@@ -88,6 +98,7 @@ GEM ...@@ -88,6 +98,7 @@ GEM
nokogiri (1.10.10) nokogiri (1.10.10)
mini_portile2 (~> 2.4.0) mini_portile2 (~> 2.4.0)
pg (1.2.3) pg (1.2.3)
public_suffix (4.0.6)
puma (3.12.6) puma (3.12.6)
rack (2.2.3) rack (2.2.3)
rack-proxy (0.6.5) rack-proxy (0.6.5)
...@@ -122,6 +133,7 @@ GEM ...@@ -122,6 +133,7 @@ GEM
rb-fsevent (0.10.4) rb-fsevent (0.10.4)
rb-inotify (0.10.1) rb-inotify (0.10.1)
ffi (~> 1.0) ffi (~> 1.0)
regexp_parser (1.8.1)
rspec-core (3.9.2) rspec-core (3.9.2)
rspec-support (~> 3.9.3) rspec-support (~> 3.9.3)
rspec-expectations (3.9.2) rspec-expectations (3.9.2)
...@@ -185,6 +197,8 @@ GEM ...@@ -185,6 +197,8 @@ GEM
websocket-driver (0.7.3) websocket-driver (0.7.3)
websocket-extensions (>= 0.1.0) websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5) websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
PLATFORMS PLATFORMS
ruby ruby
...@@ -192,6 +206,7 @@ PLATFORMS ...@@ -192,6 +206,7 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
bootsnap (>= 1.1.0) bootsnap (>= 1.1.0)
byebug byebug
capybara
factory_bot_rails factory_bot_rails
faker faker
jbuilder (~> 2.5) jbuilder (~> 2.5)
......
...@@ -14,6 +14,8 @@ export default () => ( ...@@ -14,6 +14,8 @@ export default () => (
to="/recipes" to="/recipes"
className="btn btn-lg custom-button" className="btn btn-lg custom-button"
role="button" role="button"
name="View Recipes"
id="View Recipes"
> >
View Recipes View Recipes
</Link> </Link>
......
{ {
"name": "rails_react_recipe", "name": "rails_react_recipe",
"private": true, "private": true,
"scripts": {
"test": "jest",
"test-watch": "jest --watch"
},
"dependencies": { "dependencies": {
"@babel/preset-react": "^7.10.4", "@babel/preset-react": "^7.10.4",
"@rails/webpacker": "4.3.0", "@rails/webpacker": "4.3.0",
...@@ -14,6 +18,12 @@ ...@@ -14,6 +18,12 @@
"react-router-dom": "^5.2.0" "react-router-dom": "^5.2.0"
}, },
"devDependencies": { "devDependencies": {
"jest": "^26.4.2",
"webpack-dev-server": "^3.11.0" "webpack-dev-server": "^3.11.0"
},
"jest": {
"roots": [
"test/javascript"
]
} }
} }
FactoryBot.define do
factory :random_recipe, class: Recipe do
name { Faker::Food.dish }
ingredients { Faker::Food.ingredient }
instruction { Faker::Food.description }
end
end
describe "GET '/' - from API", :type => :feature do
it 'checks the application renders or not' do
visit('http://localhost:3000/')
expect(page.title).to eq("RailsReactRecipe")
end
end
\ No newline at end of file
require 'rails_helper' require 'rails_helper'
RSpec.describe Recipe do RSpec.describe Recipe, type: :model do
describe 'Recipe Model Validation Tests' do
it 'should run the first test case' do it 'should run the first test case' do
puts 'hello world! test' puts 'hello world! test'
expect('result').to eq('result') expect('result').to eq('result')
end 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 end
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
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