In a contrast to Test Driven Development in a Behavior Driven Development you create software by describing it from the end user perspective. In BDD you didn’t test given method but a given scenario.
If you have a sign in form in your application you can create following scenarios:
- Given I am a guest when I enter sign in form and I input valid email address and password, then application redirects me to my account
- Given I am a guest when I enter sign in form and I input invalid email address and valid password, I will see an error notification
In Ruby on Rails you can implement acceptance tests using RSpec or Capybara. In order to get the best results it’s good to have both unit and acceptance tests. From the business perspective implementation details are less important than application behavior but from performance perspective is inversely.
It’s a success to satisfy both business and performance goals and proper tests are one of the best tools available to achieve this.