Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controller specs #5

Merged
merged 3 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/views/users/index.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<h1>This pages shows the users list</h1>
<h1>This page shows the users list</h1>
14 changes: 11 additions & 3 deletions spec/requests/posts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@

RSpec.describe 'Posts', type: :request do
describe 'GET /index' do
it 'returns http success' do
get '/posts/index'
it 'returns http success for Posts index page' do
get '/users/:user_id/posts'
expect(response).to have_http_status(:success)
end
it 'renders the index template for posts' do
get '/users/:user_id/posts'
expect(response.body).to include('Show posts related to user ID')
end
end
zunairkhan811 marked this conversation as resolved.
Show resolved Hide resolved

describe 'GET /show' do
it 'returns http success' do
get '/posts/show'
get '/users/:user_id/posts/:id'
expect(response).to have_http_status(:success)
end
it 'renders the show template for posts' do
get '/users/:user_id/posts/:id'
expect(response.body).to include('Show user post with specific Id')
end
end
end
21 changes: 18 additions & 3 deletions spec/requests/users_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
require 'rails_helper'

RSpec.describe 'Users', type: :request do
describe 'GET /index' do
it 'returns http success' do
get '/users/index'
describe 'GET /Index' do
it 'returns http success for Users index page' do
get '/users'
expect(response).to have_http_status(:success)
end
it 'renders the index template for users' do
get '/users'
expect(response.body).to include('This page shows the users list')
end
end

describe 'GET /show' do
it 'returns http success for users show page' do
get '/users/:id'
expect(response).to have_http_status(:success)
end
it 'renders the show template for users' do
get '/users/:id'
expect(response.body).to include('Show Users with Id')
end
end
end
Loading