Skip to content

Commit

Permalink
Merge pull request #344 from turingschool/2403_b3
Browse files Browse the repository at this point in the history
Add test env config for raising exceptions instead of showing pages for rescuable errors
  • Loading branch information
jamisonordway authored Mar 25, 2024
2 parents f425f66 + ee39a53 commit 4b2c9dd
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions module3/lessons/exercises/building_an_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ $ bundle
$ rails g rspec:install
```

By default, the Rails 7 test environment renders exception templates for rescuable exceptions. You can find this configuration in `config/environments/test.rb`:

```ruby
# Render exception templates for rescuable exceptions and raise for other exceptions.
config.action_dispatch.show_exceptions = :rescuable
```

Since we want the raised exception to print to our terminal in the case of failing tests, change this line to the following:

```ruby
config.action_dispatch.show_exceptions = :none
```

The wording here is a bit misleading, but don't worry. This change makes it so that RSpec will show us any raised exceptions instead of trying to render an HTML document for the ones that are rescuable.

Now let's get our factories set up!

add `gem "factory_bot_rails"``gem "faker"` to your :development, :test block in your Gemfile. Remember to bundle afterwards.
Expand Down

0 comments on commit 4b2c9dd

Please sign in to comment.