spec/boltless/request_spec.rb in boltless-1.3.0 vs spec/boltless/request_spec.rb in boltless-1.4.0

- old
+ new

@@ -80,26 +80,26 @@ } ] end it 'returns 4 results' do - expect(action.count).to be_eql(4) + expect(action.count).to be(4) end it 'returns the expected results (first 3)' do - expect(action[0..2].map(&:count)).to all(be_eql(0)) + expect(action[0..2].map(&:count)).to all(eql(0)) end it 'returns the expected results (last)' do - expect(action.last.value).to be_eql('Bernd') + expect(action.last.value).to eql('Bernd') end it 'does not write the data actually' do count = instance.one_shot_transaction( { statement: 'MATCH (n:User) RETURN count(n)' } ).first.value - expect(count).to be_eql(0) + expect(count).to be(0) end end describe '.statement_payloads' do let(:action) { ->(*args) { described_class.statement_payloads(*args) } } @@ -107,11 +107,11 @@ it 'returns an Array' do expect(action.call).to be_a(Array) end it 'returns an array with the converted statements' do - expect(action.call(['a', { a: true }], ['b', {}]).count).to be_eql(2) + expect(action.call(['a', { a: true }], ['b', {}]).count).to be(2) end it 'returns an array of converted statement Hashes' do expect(action.call(['a', { a: true }], ['b', {}])).to all(be_a(Hash)) end @@ -182,12 +182,11 @@ let(:action) { ->(*args) { instance.one_shot_transaction(*args) } } let(:body) { '{}' } let(:req_body) { { statements: statements }.to_json } before do - allow(connection).to receive(:headers).and_return(connection) - allow(connection).to receive(:post).and_return(response) + allow(connection).to receive_messages(headers: connection, post: response) end context 'without statements' do it 'raises an ArgumentError' do expect { action.call }.to \ @@ -222,12 +221,11 @@ describe '#begin_transaction' do let(:action) { ->(*args) { instance.begin_transaction(*args) } } let(:body) { '{}' } before do - allow(connection).to receive(:headers).and_return(connection) - allow(connection).to receive(:post).and_return(response) + allow(connection).to receive_messages(headers: connection, post: response) end it 'sets the correct access mode header' do expect(connection).to \ receive(:headers).with('Access-Mode' => 'WRITE').and_call_original @@ -257,11 +255,11 @@ context 'with an successful response with Location header' do let(:headers) { { 'location' => 'http://neo4j:7474/db/neo4j/tx/3894' } } it 'returns the correct transaction identifier' do - expect(action.call).to be_eql(3894) + expect(action.call).to be(3894) end end describe 'logging' do let(:headers) { { 'location' => 'http://neo4j:7474/db/neo4j/tx/3894' } } @@ -490,11 +488,11 @@ it 'does not raise errors' do expect { action }.not_to raise_error end it 'returns an empty array' do - expect(action).to match_array([]) + expect(action).to be_empty end end context 'with results' do let(:body) { { results: raw_results }.to_json } @@ -612,11 +610,11 @@ safe_action end it 'passes over the raw response body' do Boltless.configuration.raw_response_handler = proc do |body, _res| - expect(body).to be_eql('{"test":true}') + expect(body).to eql('{"test":true}') body end action end @@ -633,23 +631,23 @@ describe '#serialize_body' do let(:action) { ->(obj) { instance.serialize_body(obj) } } context 'with an Array' do it 'returns the expected JSON representation' do - expect(action[[1, [2]]]).to be_eql('[1,[2]]') + expect(action[[1, [2]]]).to eql('[1,[2]]') end end context 'with a Hash' do it 'returns the expected JSON representation' do - expect(action[{ a: { b: true } }]).to be_eql('{"a":{"b":true}}') + expect(action[{ a: { b: true } }]).to eql('{"a":{"b":true}}') end end context 'with a String' do it 'returns the expected JSON representation' do - expect(action['test']).to be_eql('"test"') + expect(action['test']).to eql('"test"') end end end describe '#handle_transport_errors' do @@ -688,11 +686,11 @@ it 'yields the user block' do expect { |control| action[&control] }.to yield_control end it 'returns the result of the user block' do - expect(action.call).to be_eql(923) + expect(action.call).to be(923) end it 'does not change the request counter' do expect { action.call }.not_to \ change { instance.instance_variable_get(:@requests_done) }.from(0) @@ -710,11 +708,11 @@ it 'yields the user block' do expect { |control| action[&control] }.to yield_control end it 'returns the result of the user block' do - expect(action.call).to be_eql(923) + expect(action.call).to be(923) end it 'change the request counter' do expect { action.call }.to \ change { instance.instance_variable_get(:@requests_done) } @@ -775,11 +773,11 @@ it 'yields the user block' do expect { |control| action[&control] }.to yield_control end it 'returns the result of the user block' do - expect(action.call).to be_eql(923) + expect(action.call).to be(923) end it 'calls the logger twice' do expect(Boltless.logger).to receive(:debug).twice action.call @@ -915,11 +913,11 @@ end end context 'with a single statement' do it 'returns a string with a single line' do - expect(action.lines.count).to be_eql(1) + expect(action.lines.count).to be(1) end it 'resolves the Cypher statement with the parameters' do expect(action).to include('RETURN 2') end @@ -938,10 +936,10 @@ } ] end it 'returns a string with two lines' do - expect(action.lines.count).to be_eql(2) + expect(action.lines.count).to be(2) end it 'resolves the Cypher statement with the parameters (1)' do expect(action).to include('RETURN 2') end