...now, Chapter 8 is currently work in progress for the Rails 7 version Documentation for rspec-core Using metadata attributes to write spec-type specific before blocks Shared examples and...
...method and observe its return value or side effects. Your MovieDB already uses the gem rspec-rails which has many different types of specs. These help you take a close...
...cons of end-to-end tests ("E2E tests", "full-stack integration tests"). Learn basic RSpec for unit tests ("model specs") and E2E tests ("features") Learn to use Capybara to control...
...the implementation. Learn how to run tests in existing applications. Learn about Geordi's rspec and tests commands Learn when to write unit tests, when to write integration tests, when...
...p and following the guidelines from the referred card above. If you are debugging rspec tests, you can use rspec -b to print the full stack trace. If you encounter...
...local Rails server's log ..or tail -f log/test.log to see the same for RSpec tests! Different debugging libraries Ruby has always had multiple gems for debugging. When you're...
...horizon').where('year > 1995').order(:year).to_a Adapt both the integration test and RSpec examples for the search functionality, using the guidelines from the "Testing" chapter in Growing Rails...
...Applications in Practice. RSpec examples should cover all edge cases E2E tests should only cover one "happy path" to show successful integration Open budgets in Project Hero (makandra only)
...just say create(:movie) instead of FactoryBot.create(:movie). You can configure this like so: RSpec.configure do |config| config.include FactoryBot::Syntax::Methods end Also see RSpec: Where to put custom matchers...
...file uploads with Rails Carrierwave: How to attach files in tests Carrierwave: Built-in RSpec matchers CarrierWave: Processing images with libvips Multipart formposts Content Disposition Header Exercise In MovieDB, allow...
Rendering of image versions and validation of file extension can be tested with RSpec These can be model specs for either the Movie or your PosterUploader
...which kinds of validations are built into Rails. Also read Testing ActiveRecord validations with RSpec. Make the following changes to your MovieDB: Make sure your MovieDB models have validations for...
...API from the example (skip this variant for the "upcoming movie" exercise) Use plain RSpec mocks ("stubs") to replace the HTTP request to the API with scripted behavior. Can you...
...s poster as a file attachment to the e-mail? Can you write a RSpec test for this? In the lesson Form Models we said that we don't like...
Best results in other decks
...Remove default rules BrowserConsole.ignore_nothing # Add your own rules BrowserConsole.ignore(...) BrowserConsole.ignore(...) Automatic checking in RSpec feature specs In your spec_helper.rb you may configure to automatically check for errors after every...
...A compromise might be to only check the console when the spec has ended: RSpec.configure do |config| config.after do BrowserConsole.assert_no_errors! end end Ignoring JavaScript errors for a spec...
Add in Gemfile: group :development, :test do gem 'rspec-rails' gem 'spork-rails' end group :test do gem 'capybara' gem 'database_cleaner' gem 'email_spec' gem 'poltergeist' gem 'launchy'
...controllers will be inferred # automatically. This will be the default behavior in future versions of # rspec-rails. config.infer_base_class_for_anonymous_controllers = true # Run specs in random order to...