Testing Rails apps that use Pusher with pusher-fake
Blog post from Semaphore
Pusher is a cloud service used to send real-time messages to users' web browsers, offering benefits such as reliable uptime and excellent customer service, which can simplify infrastructure management. Semaphore utilizes Pusher to update various status changes on its build page, enabling seamless user experiences by sending signals for page reloads via Turbolinks. Testing systems that rely on external APIs like Pusher can be challenging, often requiring the use of stubbed methods to simulate interactions. However, for Pusher, a more integrated approach is preferred, involving the use of pusher-fake, a tool that mimics Pusher's server functionality over localhost, allowing for realistic testing environments. This involves minimal code changes, such as loading specific JavaScript in test environments and modifying the Pusher library’s implementation in Rails applications, which can be facilitated through tools like Cucumber for scenario testing.