Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Commit

Permalink
Always install the snappy gem so that the compression tests can run
Browse files Browse the repository at this point in the history
  • Loading branch information
iconara committed Jan 1, 2014
1 parent 288373c commit 8630c87
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -3,12 +3,12 @@ source 'https://rubygems.org/'
gemspec gemspec


gem 'rake' gem 'rake'
gem 'snappy'


group :development do group :development do
gem 'pry' gem 'pry'
gem 'viiite' gem 'viiite'
gem 'travis-lint' gem 'travis-lint'
gem 'snappy'
platforms :mri do platforms :mri do
gem 'yard' gem 'yard'
gem 'redcarpet' gem 'redcarpet'
Expand Down
40 changes: 16 additions & 24 deletions spec/integration/protocol_spec.rb
Expand Up @@ -370,31 +370,23 @@ def in_keyspace_with_counters_table
end end


context 'with compression' do context 'with compression' do
begin let :compressor do
require 'cql/compression/snappy_compressor' Cql::Compression::SnappyCompressor.new(0)

end
let :compressor do
Cql::Compression::SnappyCompressor.new(0)
end


it 'sends a compressed request and receives a compressed response' do it 'sends a compressed request and receives a compressed response' do
compressor.stub(:compress).and_call_original compressor.stub(:compress).and_call_original
compressor.stub(:decompress).and_call_original compressor.stub(:decompress).and_call_original
io_reactor = Cql::Io::IoReactor.new(lambda { |*args| Cql::Protocol::CqlProtocolHandler.new(*args, compressor) }) io_reactor = Cql::Io::IoReactor.new(lambda { |*args| Cql::Protocol::CqlProtocolHandler.new(*args, compressor) })
io_reactor.start.value io_reactor.start.value
begin begin
connection = io_reactor.connect(ENV['CASSANDRA_HOST'], 9042, 0.1).value connection = io_reactor.connect(ENV['CASSANDRA_HOST'], 9042, 0.1).value
connection.send_request(Cql::Protocol::StartupRequest.new(nil, 'snappy')).value connection.send_request(Cql::Protocol::StartupRequest.new(nil, 'snappy')).value
connection.send_request(Cql::Protocol::PrepareRequest.new('SELECT * FROM system.peers')).value connection.send_request(Cql::Protocol::PrepareRequest.new('SELECT * FROM system.peers')).value
compressor.should have_received(:compress).at_least(1).times compressor.should have_received(:compress).at_least(1).times
compressor.should have_received(:decompress).at_least(1).times compressor.should have_received(:decompress).at_least(1).times
ensure ensure
io_reactor.stop.value io_reactor.stop.value
end
end
rescue LoadError
it 'compresses requests and decompresses responses' do
pending 'No compressor available for the current platform'
end end
end end
end end
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Expand Up @@ -26,3 +26,4 @@
end end


require 'cql' require 'cql'
require 'cql/compression/snappy_compressor'

0 comments on commit 8630c87

Please sign in to comment.