From the course: Ruby: Testing with RSpec
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Transactional examples - Ruby Tutorial
From the course: Ruby: Testing with RSpec
Transactional examples
- In this movie we'll learn how the test database affects your examples, by learning about Transactional Examples. By default in RSpec Rails, each example runs inside a transaction. What that means is that when the example finishes database changes are going to be rolled back. Anything you do will be undone. This is a configuration option, you can actually set it in the rails_helper. You'll find a line that says something like config.use_transactional_fixtures = true, or it might say use_transactional_examples. Transactional examples is an alias for transactional fixtures. Personally I think this second one is clearer, but at least at the moment the default config file contains the first version. That may change in the future, so I wanted you to see both. Let me give you an example of what this looks like. Let's imagine I have a Spec for the customer model. My first example is that it has 0 customers at the start. So I would expect that if I call Customer.count it will return 0, the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.