Behavior-driven development

BDD is about implementing an application by describing its behaviour from the perspective of its stakeholders.

  • User stories
  • Domain-Driven Development
  • Extreme Programming
    • Test-Driven Development
    • Acceptance Driven Test Planning
    • Continuous Integration

Bdd cycle

  1. Start with an Acceptance Test scenatio.
  2. Run the Acceptance Test scenatio.
  3. Red/Green/Refactor wuth Unit Tests.
    • View
    • Controller
    • Model
  4. Run the Acceptance Test scenatio again.

Init enviropment

Create gemset

Install Rails

Create Application

Add gems


Init testing tools

Init RSpec

config/application.rb spec/spec_helper.rb spec/features/features_spec_helper.rb

Meet the Capybara

Capybara is acceptance test framework for web applications.

Capybara helps to test web applications by simulating how a real user would interact with an app.

Test your app with Capybara

Registration feature


Fix 'register_path' error


Fix uninitialized constant UsersController


Fix the action 'new' could not be found for UsersController


Fix missing template 'users/new'

app/views/users/new.html.erb created

View specs

spec/views/users/new_spec.rb app/views/users/new.html.erb config/routes.rb

More view specs

spec/views/users/new_spec.rb app/views/users/new.html.erb Run views Run features

Controller specs

spec/controllers/users_controller_spec.rb app/controllers/users_controller.rb

Model specs

spec/models/user_spec.rb app/models/user.rb

Fix the action 'create' could not be found error

spec/controllers/users_controller_spec.rb app/controllers/users_controller.rb

Fix undefined local variable or method 'root_url' error

config/routes.rb app/controllers/pages_controller.rb

app/views/pages/home.html.erb created

Fix expected to find text 'Sign out'


Fix expected to find text 'You registered'



You need to write a simple web book store. Please implement the following user stories.