This is a cheat sheet for RSpec, including its methods, and test doubles. It also includes FactoryGirl methods, even though that is separate from RSpec. This cheat sheet is based on Rails 4 Test Prescriptions by Noel Rappin (the best of a bad lot when it comes to RSpec books) and the RSpec documentation published on Relish. RSpec documentation is generally not very good, which is why I created this cheat sheet for myself.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |