testing-patterns-ruby
Installation
SKILL.md
Testing Couchbase Ruby Applications
Unit Testing
Use RSpec doubles to mock the collection.
# Gemfile
gem 'rspec', '~> 3.12', group: :test
RSpec.describe UserRepository do
let(:mock_collection) { double('collection') }
let(:mock_result) { double('get_result', content: { 'name' => 'Alice' }) }
it 'returns the correct document' do
allow(mock_collection).to receive(:get).with('user::alice').and_return(mock_result)