Writing a request spec / test in Rails with authentication

What good is it to have an application if you don't know if it works? By writing automated tests around the most useful/important pieces of your application, you can build with confidence. And if you need to make a change to your code, you can know immediately if it still works.
Using Rspec, I build out an automated request spec to make requests against multiple API endpoints. Each endpoint has a different purpose, and I show how to write tests for both authenticated and unauthenticated users.
⏱️ Timestamps: 00:00 - Introduction 00:31 - End result 00:45 - Installing rspec rails 01:39 - routes.rb 02:19 - applicationcontroller.rb 02:42 - pingcontroller.rb 03:00 - pingrequestspec.rb 04:19 - spec support - object creators 06:30 - devise specific controllers 09:45 - other files
💌 Newsletter: https://www.programmingtil.com/
🪐Elsewhere: Twitter: https://twitter.com/davidwparker Twitter: https://twitter.com/programmingtil GitHub: https://github.com/davidwparker
  • Rspec
  • Request Spec
  • Devise
  • Authorization
  • authenticateuser!

  • https://github.com/davidwparker/programmingtil-rails/tree/ep5
  • https://github.com/rspec/rspec-rails

🎬 Subscribe! http://bit.ly/subdavidwparker
My name is David W Parker and I’m creating and publishing videos on ProgrammingTIL to help teach anyone and everyone who wants to code. I’m a huge fan of Ruby on Rails, Svelte, and WebGL. I’ve used React a lot in the past, as well as some Vue and AngularJS. I’ve done some professional Python and Django as well. I like to create real applications and my tutorials will walk you through how to build something real from beginning-to-end.

ruby #rails #rubyonrails

© programmingtil.com