Sha256: 48f36a6f305ecceda731b0d254023f5415a8d23497d078e176cffce0bcbba005
Contents?: true
Size: 1.29 KB
Versions: 2
Compression:
Stored size: 1.29 KB
Contents
require 'spec_helper' module I3Ipc describe Connection do describe '#command' do before(:all) do class Connection def initialize @protocol = Protocol.new '' end end end it 'returns Reply object' do allow_any_instance_of(Protocol).to receive(:send) allow_any_instance_of(Protocol).to receive(:receive) .and_return("{}") expect(Connection.new.command('cmd')).to be_a Reply end it 'sends correct command and receives success response' do allow_any_instance_of(Protocol).to receive(:send) allow_any_instance_of(Protocol).to receive(:receive) .and_return(%Q[{"success": true}]) connection = Connection.new reply = connection.command('focus left') expect(reply.success).to be true end it 'sends incorrect command and receives error response' do allow_any_instance_of(Protocol).to receive(:send) allow_any_instance_of(Protocol).to receive(:receive) .and_return(%Q[{"success": false, "error": "wrong command"}]) connection = Connection.new reply = connection.command('my command') expect(reply.success).to be false expect(reply.error).to eql 'wrong command' end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
i3ipc-0.2.0 | spec/i3ipc/connection_spec.rb |
i3ipc-0.1.0 | spec/i3ipc/connection_spec.rb |