Testing Object Registry Management in Bullet Framework
This test suite validates the Object registry functionality in the Bullet gem, focusing on key management and object tracking capabilities. The tests ensure proper object registration and lookup mechanisms that are essential for Bullet’s N+1 query detection.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
flyerhzm/bullet
spec/bullet/registry/object_spec.rb
# frozen_string_literal: true
require 'spec_helper'
using Bullet::Ext::Object
module Bullet
module Registry
describe Object do
let(:post) { Post.first }
let(:another_post) { Post.last }
subject { Object.new.tap { |object| object.add(post.bullet_key) } }
context '#include?' do
it 'should include the object' do
expect(subject).to be_include(post.bullet_key)
end
end
context '#add' do
it 'should add an object' do
subject.add(another_post.bullet_key)
expect(subject).to be_include(another_post.bullet_key)
end
end
end
end
end