Today I Learned

Testing an Independent Mixin With RSpec

Objective: write a spec for the Inventory::Query mixin.

Note: the mixin is independent of the including class as it does not depend on any instance variables or instance methods.

Original Approach

class InventoryQueryTest
  include Inventory::Query
subject(:inventory_query) { }

Preferred Approach

subject(:inventory_query) { ( { include Inventory::Query }).new }


Simpler and avoids polluting the global namespace with a test class.