spec/lib/flare_up/connection_spec.rb in flare-up-0.6 vs spec/lib/flare_up/connection_spec.rb in flare-up-0.7

- old
+ new

@@ -2,10 +2,12 @@ subject do FlareUp::Connection.new('TEST_HOST', 'TEST_DB_NAME', 'TEST_USER', 'TEST_PASSWORD') end + let(:mock_pg_connection) { instance_double('PGConn') } + its(:host) { should == 'TEST_HOST' } its(:port) { should == 5439 } its(:dbname) { should == 'TEST_DB_NAME' } its(:user) { should == 'TEST_USER' } its(:password) { should == 'TEST_PASSWORD' } @@ -95,20 +97,42 @@ end end describe '#connection_parameters' do - it 'should return the required parameters' do expect(subject.send(:connection_parameters)).to eq({ :host => 'TEST_HOST', :port => 5439, :dbname => 'TEST_DB_NAME', :user => 'TEST_USER', :password => 'TEST_PASSWORD', :connect_timeout => 5, + :keepalives => 1, + :keepalives_idle => 30, + :keepalives_interval => 10, + :keepalives_count => 3 }) end + end + describe '#execute' do + before do + allow(subject).to receive(:connect).and_return(mock_pg_connection) + end + it 'should execute the specified command' do + expect(mock_pg_connection).to receive(:async_exec).with('TEST_STATEMENT') + subject.execute('TEST_STATEMENT') + end + end + + describe '#cancel_current_command' do + before do + allow(subject).to receive(:connect).and_return(mock_pg_connection) + end + it 'should execute the specified command' do + expect(mock_pg_connection).to receive(:cancel) + subject.cancel_current_command + end end end \ No newline at end of file