Skip to content

glowacki-dev/testifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README

This is a basic project (one model, one controller) to demonstrate an idea of writing tests easier and faster than using conventional approach.

More information and some backstory can be found in this Medium story.

tl;dr

We use rspec_api_documentation to write documentation and create acceptance tests at the same time. To make those tests easier to write let's use a wrapper class (or a DSL if you like) which we'll call ApiRequest. It's responsible for preparing our test constraints, requests stubs and email messages expectations. To easily use this in our tests we can use a shared example.

You can see an example spec for our controller to see it in action. Those tests check response status and body, but also make sure that all web requests and emails were properly stubbed, so we don't forget about anything. Having done all that you can write some additional expectations as well.

Generating documentation

After cloning this project locally, and installing all required gems with bundle install you can run tests and generate documentation with RAILS_ENV=test rake docs:generate.

You can then view those docs under http://localhost:3000/docs once you start a server with rails server.