No commit activity in last 3 years
No release in over 3 years
Websocket VCR add-on
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.8
~> 11
= 0.34.2
~> 3.5
~> 2.9
~> 1.7

Runtime

 Project Readme

Simple websocket VCR

Build Status Coverage Code Climate Gem Version

Based on the idea of vcr project which record the http interactions and store them as files that can be replayed later and simulate the real communication counterpart (mostly server).

However, this projects aims on the web socket protocol where normally there is only a single HTTP connection and multiple messages or frames being sent over the channel.

Usage

  it 'should record also the outgoing communication' do
    WebSocketVCR.configure do |c|
      c.hook_uris = [HOST]
    end
    WebSocketVCR.record(example, self) do
      puts 'we are recording..' if WebSocketVCR.live?
      url = "ws://#{HOST}/hawkular/command-gateway/ui/ws"
      c = WebSocket::Client::Simple.connect url do |client|
        client.on(:message, once: true, &:data)
      end
      sleep 1 if WebSocketVCR.live?
      c.send('something 1')
      c.send('something 2')
      c.send('something 3')

      expect(c).not_to be nil
      expect(c.open?).to be true
    end
  end

(source)

after running the code above, you should end up with a file that captured the interactions.

---
websocket_interactions:
- - operation: read
    event: message
    type: text
    data: WelcomeResponse={"sessionId":"XQVVtE53wxz1lmMsqz2TbmR68ilFzDxLOOpkKGpd"}
  - operation: write
    send: message
    data: something 1
  - operation: write
    send: message
    data: something 2
  - operation: write
    send: message
    data: something 3

(source)

For more details consult the specs.