Skip to content

Instantly share code, notes, and snippets.

@stevo
Last active April 6, 2022 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevo/6d27017232310db14bf88320ea722913 to your computer and use it in GitHub Desktop.
Save stevo/6d27017232310db14bf88320ea722913 to your computer and use it in GitHub Desktop.
class BookingsController < ApplicationController
def index
# `order` was added prematurely and in the result may remain untested
bookings = Booking.order(customer_name: :asc)
render :index, locals: { bookings: bookings }
end
end
RSpec.describe BookingsController do
describe '#index' do
it 'renders all bookings' do
bookings = create_list(:booking, 5)
allow(controller).to receive(:render).and_call_original
get :index
expect(controller).to have_received(:render).
with(:index, locals: { bookings: match_array(bookings) })
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment