Open in app
Home
Notifications
Lists
Stories

Write
Nikita Kharitonov
Nikita Kharitonov

Home

Jun 17, 2021

Rspec — Use mocks in the proper way

Rspec — Use mocks in the proper way Setup Nobody likes when the controller contains too much business logic and becomes fat. Let's start with one simple controller: class ReservationsController < ActionController::Base def create book = Book.available.find_by(isbn: params[:isbn]) if book BookReservation.create(user: current_user) book.update(available_count: book.available_count--) …

Rspec

3 min read

Nikita Kharitonov

Nikita Kharitonov

Help

Status

Writers

Blog

Careers

Privacy

Terms

About

Knowable