

Most people who are using RSpec are using it on Rails applications. We should also discuss how RSpec fits with the popular web framework Ruby on Rails, because Ruby on Rails is the most common use there is for RSpec. If you need to learn more about Ruby, you can take my Ruby Essential Training course to get a good primer. Make sure that you learn Ruby first, and then you'll be able to learn that DSL layer that RSpec adds on top of Ruby. But you will use Ruby a lot, and you need to be proficient in Ruby. Sometimes you'll even find that it's not very Ruby-like in the way that it does things. That's a fancy way of saying that RSpec has its own way of doing things, that we have to talk to RSpec in its own language, not just in Ruby. But it uses a domain-specific language, or DSL for short. We're just going to be formalizing this Given.

It will be rejected and the user will be notified about the problems on the form. Given that web form, when I fill out the form with bad data and submit it, then I expect that the outcome is that the form will not be submitted. In our previous example, given that we have a web form, if we fill out that form with valid data and submit it, then I expect that the outcome is that it will be submitted to the database. And it's the basic structure of all tests, so you want to make sure that you're familiar with that. Given this controlled context, if we do something, we want to test whether we get the right outcome. Given some context, when some event occurs, then I expect some outcome, and that was what was alluded to in that formal definition.
RUBY RSPEC TUTORIAL SOFTWARE
There's a basic structure to software tests that RSpec follows. A spec can also be referred to as an example or as a test, and they're used fairly interchangeably. We'll elaborate on that in just a moment.

RUBY RSPEC TUTORIAL CODE
Or more formally, it's an executable example that tests whether a portion of code exhibits the expected behavior in a controlled context. A specification is a detailed requirement that our code should meet. The "R" stands for Ruby, and "Spec" is short for Specification. RSpec is a framework that allows us to do that. So when we talk about testing, we're talking about writing code than can perform tests on other code. But you know what's great at performing repetitive tasks? Computers. Every time you make a change to your code, you have to test it again, manually.
RUBY RSPEC TUTORIAL MANUAL
That's testing, but it's manual testing, and it can be tedious and repetitive. You submit the same form again, but this time using bad data to see if your code rejects the form and tells the user about the problem. You might create a web form and then submit the form to see if it successfully adds the data to the database. You write a bit of code, and then you try it to see if it works. If you're a developer, then you've already performed software tests, whether you realize it or not. What is it? RSpec is a testing framework, so we first need to understand what a test is.
