lib/submodules/ably-ruby/spec/acceptance/rest/client_spec.rb in ably-rest-1.1.6 vs lib/submodules/ably-ruby/spec/acceptance/rest/client_spec.rb in ably-rest-1.1.7
- old
+ new
@@ -1079,33 +1079,19 @@
expect(client.auth.options[:auth_url]).to eql(dummy_auth_url)
end
end
context 'version headers', :webmock do
- [nil, 'foo'].each do |variant|
- context "with variant #{variant ? variant : 'none'}" do
- if variant
- before do
- Ably.lib_variant = variant
- end
+ [nil, 'ably-ruby/1.1.1 ruby/1.9.3'].each do |agent|
+ context "with #{agent ? "custom #{agent}" : 'default'} agent" do
+ let(:client_options) { default_options.merge(key: api_key, agent: agent) }
- after do
- Ably.lib_variant = nil
- end
- end
-
- let(:client_options) { default_options.merge(key: api_key) }
let!(:publish_message_stub) do
- lib = ['ruby']
- lib << variant if variant
- lib << Ably::VERSION
-
-
stub_request(:post, "#{client.endpoint}/channels/foo/publish").
with(headers: {
'X-Ably-Version' => Ably::PROTOCOL_VERSION,
- 'X-Ably-Lib' => lib.join('-')
+ 'Ably-Agent' => agent || Ably::AGENT
}).
to_return(status: 201, body: '{}', headers: { 'Content-Type' => 'application/json' })
end
it 'sends a protocol version and lib version header (#G4, #RSC7a, #RSC7b)' do
@@ -1115,11 +1101,11 @@
end
end
end
end
- context '#request (#RSC19*)' do
+ context '#request (#RSC19*, #TO3l9)' do
let(:client_options) { default_options.merge(key: api_key) }
let(:device_id) { random_str }
let(:endpoint) { client.endpoint }
context 'get' do
@@ -1170,10 +1156,16 @@
it 'supports post' do
response = client.request(:delete, "push/deviceRegistrations/#{device_id}/resetUpdateToken")
expect(response).to be_success
end
+
+ it 'raises an exception once body size in bytes exceeded' do
+ expect {
+ client.request(:post, endpoint, {}, { content: 'x' * Ably::Rest::Client::MAX_FRAME_SIZE })
+ }.to raise_error(Ably::Exceptions::MaxFrameSizeExceeded)
+ end
end
context 'delete', :webmock do
before do
stub_request(:delete, "#{endpoint}/push/channelSubscriptions?deviceId=#{device_id}").
@@ -1199,10 +1191,16 @@
it 'supports patch' do
response = client.request(:patch, "/push/deviceRegistrations/#{device_id}", {}, body_params)
expect(response).to be_success
end
+
+ it 'raises an exception once body size in bytes exceeded' do
+ expect {
+ client.request(:patch, endpoint, {}, { content: 'x' * Ably::Rest::Client::MAX_FRAME_SIZE })
+ }.to raise_error(Ably::Exceptions::MaxFrameSizeExceeded)
+ end
end
context 'put', :webmock do
let(:body_params) do
{
@@ -1221,9 +1219,15 @@
it 'supports put' do
response = client.request(:put, "/push/deviceRegistrations/#{device_id}", {}, body_params)
expect(response).to be_success
+ end
+
+ it 'raises an exception once body size in bytes exceeded' do
+ expect {
+ client.request(:put, endpoint, {}, { content: 'x' * Ably::Rest::Client::MAX_FRAME_SIZE })
+ }.to raise_error(Ably::Exceptions::MaxFrameSizeExceeded)
end
end
end
context 'request_id generation' do