ashikawa-core 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/{config/rubocop.yml → .hound.yml} +17 -2
  4. data/.ruby-version +1 -1
  5. data/.travis.yml +6 -6
  6. data/CHANGELOG.md +22 -0
  7. data/Gemfile +3 -4
  8. data/Guardfile +3 -3
  9. data/README.md +12 -11
  10. data/Rakefile +52 -6
  11. data/ashikawa-core.gemspec +42 -19
  12. data/config/mutant.yml +1 -3
  13. data/config/reek.yml +3 -1
  14. data/lib/ashikawa-core/collection.rb +9 -7
  15. data/lib/ashikawa-core/configuration.rb +1 -1
  16. data/lib/ashikawa-core/connection.rb +43 -0
  17. data/lib/ashikawa-core/database.rb +61 -2
  18. data/lib/ashikawa-core/error_response.rb +14 -3
  19. data/lib/ashikawa-core/exceptions/client_error.rb +4 -4
  20. data/lib/ashikawa-core/exceptions/client_error/bad_syntax.rb +3 -2
  21. data/lib/ashikawa-core/exceptions/server_error.rb +4 -4
  22. data/lib/ashikawa-core/key_options.rb +3 -2
  23. data/lib/ashikawa-core/query.rb +33 -29
  24. data/lib/ashikawa-core/status.rb +9 -0
  25. data/lib/ashikawa-core/transaction.rb +3 -3
  26. data/lib/ashikawa-core/version.rb +1 -1
  27. data/spec/acceptance/basic_spec.rb +14 -8
  28. data/spec/acceptance/index_spec.rb +2 -2
  29. data/spec/acceptance/query_spec.rb +4 -4
  30. data/spec/acceptance/spec_helper.rb +24 -9
  31. data/spec/acceptance/transactions_spec.rb +2 -2
  32. data/spec/unit/collection_spec.rb +3 -3
  33. data/spec/unit/connection_spec.rb +38 -6
  34. data/spec/unit/database_spec.rb +58 -7
  35. data/spec/unit/document_spec.rb +3 -3
  36. data/spec/unit/exception_spec.rb +5 -1
  37. data/spec/unit/index_spec.rb +6 -1
  38. data/spec/unit/query_spec.rb +32 -22
  39. data/spec/unit/spec_helper.rb +5 -20
  40. data/spec/unit/status_spec.rb +25 -25
  41. data/spec/unit/transaction_spec.rb +4 -4
  42. metadata +192 -31
  43. data/.coveralls.yml +0 -1
  44. data/Gemfile.devtools +0 -71
  45. data/config/devtools.yml +0 -5
  46. data/config/flay.yml +0 -3
  47. data/config/flog.yml +0 -3
  48. data/config/yardstick.yml +0 -2
  49. data/tasks/adjustments.rake +0 -17
@@ -25,11 +25,11 @@ describe 'Indices' do
25
25
  it 'should be possible to create an unique index' do
26
26
  index = subject.add_index :skiplist, on: [:identifier], unique: true
27
27
 
28
- expect(index.unique).to be_true
28
+ expect(index.unique).to be_truthy
29
29
  end
30
30
 
31
31
  it 'should be possible to remove indices' do
32
- pending 'See Bug #34'
32
+ skip 'See Bug #34'
33
33
 
34
34
  expect {
35
35
  index.delete
@@ -16,22 +16,22 @@ describe 'Queries' do
16
16
  collection.create_document({ 'name' => 'Jeffrey Lebowski', 'bowling' => false })
17
17
 
18
18
  names = database.query.execute(query, options).map { |person| person['name'] }
19
- expect(names).to include 'Jeff Lebowski'
19
+ expect(names).to include 'Jeff Lebowski'
20
20
  expect(names).not_to include 'Jeffrey Lebowski'
21
21
  end
22
22
 
23
23
  it 'should be possible to validate' do
24
24
  valid_query = 'FOR u IN my_collection FILTER u.bowling == true RETURN u'
25
- expect(database.query.valid?(valid_query)).to be_true
25
+ expect(database.query.valid?(valid_query)).to be_truthy
26
26
 
27
27
  invalid_query = 'FOR u IN my_collection FILTER u.bowling == true'
28
- expect(database.query.valid?(invalid_query)).to be_false
28
+ expect(database.query.valid?(invalid_query)).to be_falsey
29
29
  end
30
30
  end
31
31
 
32
32
  describe 'simple query via collection object' do
33
33
  subject { collection }
34
- before(:each) { subject.truncate! }
34
+ before(:each) { subject.truncate }
35
35
 
36
36
  it 'should return all documents of a collection' do
37
37
  subject.create_document({ name: 'testname', age: 27 })
@@ -14,17 +14,32 @@ end
14
14
 
15
15
  require 'ashikawa-core'
16
16
 
17
- port = ENV.fetch('ARANGODB_PORT', 8529)
18
- username = ENV.fetch('ARANGODB_USERNAME', 'root')
19
- password = ENV.fetch('ARANGODB_PASSWORD', '')
20
- authentification_enabled = ENV['ARANGODB_DISABLE_AUTHENTIFICATION'] == 'false'
17
+ PORT = ENV.fetch('ARANGODB_PORT', 8529)
18
+ USERNAME = ENV.fetch('ARANGODB_USERNAME', 'root')
19
+ PASSWORD = ENV.fetch('ARANGODB_PASSWORD', '')
20
+ AUTHENTIFICATION_ENABLED = ENV['ARANGODB_DISABLE_AUTHENTIFICATION'] == 'false'
21
21
 
22
- # The database instance to use for all specs
22
+ # System Database for general use in specs
23
23
  DATABASE = Ashikawa::Core::Database.new do |config|
24
- config.url = "http://localhost:#{port}"
24
+ config.url = "http://localhost:#{PORT}"
25
25
 
26
- if authentification_enabled
27
- config.username = username
28
- config.password = password
26
+ if AUTHENTIFICATION_ENABLED
27
+ config.username = USERNAME
28
+ config.password = PASSWORD
29
+ end
30
+ end
31
+
32
+ def database_with_random_name
33
+ # This results in a database that has a valid name according to:
34
+ # https://www.arangodb.org/manuals/2/NamingConventions.html#DatabaseNames
35
+ name = "a#{rand.to_s[2, 10]}"
36
+
37
+ Ashikawa::Core::Database.new do |config|
38
+ config.url = "http://localhost:#{PORT}/_db/#{name}"
39
+
40
+ if AUTHENTIFICATION_ENABLED
41
+ config.username = USERNAME
42
+ config.password = PASSWORD
43
+ end
29
44
  end
30
45
  end
@@ -12,8 +12,8 @@ describe 'Transactions' do
12
12
  end
13
13
 
14
14
  let(:js_function) { 'function (x) { return x.a; }' }
15
- let(:write_collections) { %w{collection_1 collection_2} }
16
- let(:read_collections) { %w{collection_2} }
15
+ let(:write_collections) { %w(collection_1 collection_2) }
16
+ let(:read_collections) { %w(collection_2) }
17
17
 
18
18
  it 'should create and execute a transaction' do
19
19
  transaction = subject.create_transaction js_function, write: write_collections, read: read_collections
@@ -94,7 +94,7 @@ describe Ashikawa::Core::Collection do
94
94
  expect(database).to receive(:send_request)
95
95
  .with('collection/60768679/truncate', put: {})
96
96
 
97
- subject.truncate!
97
+ subject.truncate
98
98
  end
99
99
 
100
100
  it 'should change its name' do
@@ -169,7 +169,7 @@ describe Ashikawa::Core::Collection do
169
169
  it 'should add a new index' do
170
170
  expect(database).to receive(:send_request)
171
171
  .with('index?collection=60768679', post: {
172
- 'type' => 'hash', 'fields' => %w{a b}, 'unique' => false
172
+ 'type' => 'hash', 'fields' => %w(a b), 'unique' => false
173
173
  })
174
174
  .and_return(index_response)
175
175
  expect(Ashikawa::Core::Index).to receive(:new)
@@ -181,7 +181,7 @@ describe Ashikawa::Core::Collection do
181
181
  it 'should add a new unique index' do
182
182
  expect(database).to receive(:send_request)
183
183
  .with('index?collection=60768679', post: {
184
- 'type' => 'hash', 'fields' => %w{a b}, 'unique' => true
184
+ 'type' => 'hash', 'fields' => %w(a b), 'unique' => true
185
185
  })
186
186
  .and_return(index_response)
187
187
  expect(Ashikawa::Core::Index).to receive(:new)
@@ -42,7 +42,7 @@ describe Ashikawa::Core::Connection do
42
42
  end
43
43
 
44
44
  it 'should send a delete request' do
45
- request_stub.delete('/_api/my/path') do |request|
45
+ request_stub.delete('/_api/my/path') do |_|
46
46
  [200, response_headers, JSON.generate({ 'name' => 'dude' })]
47
47
  end
48
48
 
@@ -50,20 +50,52 @@ describe Ashikawa::Core::Connection do
50
50
  request_stub.verify_stubbed_calls
51
51
  end
52
52
 
53
+ context 'with database suffix' do
54
+ let(:database_name) { 'ashikawa' }
55
+ subject do
56
+ Ashikawa::Core::Connection.new("#{ARANGO_HOST}/_db/#{database_name}", adapter: [:test, request_stub])
57
+ end
58
+
59
+ its(:database_name) { should eq database_name }
60
+
61
+ let(:options) { double('Options') }
62
+ it 'should be able to send a request without database suffix' do
63
+ expect(subject).to receive(:send_request)
64
+ .with("#{ARANGO_HOST}/_api/some_endpoint", options)
65
+
66
+ subject.send_request_without_database_suffix('some_endpoint', options)
67
+ end
68
+ end
69
+
70
+ context 'without database suffix' do
71
+ subject do
72
+ Ashikawa::Core::Connection.new(ARANGO_HOST, adapter: [:test, request_stub])
73
+ end
74
+
75
+ its(:database_name) { should eq '_system' }
76
+ let(:options) { double('Options') }
77
+ it 'should be able to send a request without database suffix' do
78
+ expect(subject).to receive(:send_request)
79
+ .with("#{ARANGO_HOST}/_api/some_endpoint", options)
80
+
81
+ subject.send_request_without_database_suffix('some_endpoint', options)
82
+ end
83
+ end
84
+
53
85
  describe 'authentication' do
54
86
  it 'should have authentication turned off by default' do
55
- expect(subject.authentication?).to be_false
87
+ expect(subject.authentication?).to be_falsey
56
88
  end
57
89
 
58
90
  it 'should tell if authentication is enabled' do
59
91
  subject.authenticate_with('testuser', 'testpassword')
60
- expect(subject.authentication?).to be_true
92
+ expect(subject.authentication?).to be_truthy
61
93
  end
62
94
 
63
95
  it 'should send the authentication data with every GET request' do
64
- pending 'Find out how to check for basic auth via Faraday Stubs'
96
+ skip 'Find out how to check for basic auth via Faraday Stubs'
65
97
 
66
- request_stub.get('/_api/my/path') do |request|
98
+ request_stub.get('/_api/my/path') do |_|
67
99
  [200, response_headers, JSON.generate({ 'name' => 'dude' })]
68
100
  end
69
101
 
@@ -96,7 +128,7 @@ describe Ashikawa::Core::Connection do
96
128
 
97
129
  it 'should throw its own exception when doing a bad request' do
98
130
  request_stub.get('/_api/bad/request') do
99
- [400, response_headers, '']
131
+ [400, response_headers, '{}']
100
132
  end
101
133
 
102
134
  expect do
@@ -41,10 +41,52 @@ describe Ashikawa::Core::Database do
41
41
  subject.query
42
42
  end
43
43
 
44
+ let(:database_list) { double('DatabaseList') }
45
+
46
+ it 'should list all databases' do
47
+ expect(connection).to receive(:send_request)
48
+ .with('database')
49
+ .and_return({ 'result' => database_list, 'error' => false, 'code' => 200 })
50
+
51
+ expect(subject.all_databases).to be database_list
52
+ end
53
+
54
+ context "using a database called 'ashikawa'" do
55
+ before { allow(connection).to receive(:database_name).and_return('ashikawa') }
56
+
57
+ its(:name) { should eq 'ashikawa' }
58
+
59
+ describe 'create' do
60
+ it 'should be able to create itself' do
61
+ expect(connection).to receive(:send_request_without_database_suffix)
62
+ .with('database', post: { name: 'ashikawa' })
63
+
64
+ subject.create
65
+ end
66
+
67
+ it 'should return an error message if the database name is already taken' do
68
+ expect(connection).to receive(:send_request_without_database_suffix)
69
+ .with('database', post: { name: 'ashikawa' })
70
+ .and_raise(Ashikawa::Core::ClientError, '1207: duplicate name')
71
+
72
+ expect { subject.create }.to raise_error(Ashikawa::Core::ClientError, '1207: duplicate name')
73
+ end
74
+ end
75
+
76
+ describe 'drop' do
77
+ it 'should be able to drop itself' do
78
+ expect(connection).to receive(:send_request_without_database_suffix)
79
+ .with('database/ashikawa', delete: {})
80
+
81
+ subject.drop
82
+ end
83
+ end
84
+ end
85
+
44
86
  it 'should fetch all available non-system collections' do
45
87
  expect(connection).to receive(:send_request)
46
88
  .with('collection')
47
- .and_return { server_response('collections/all') }
89
+ .and_return(server_response('collections/all'))
48
90
 
49
91
  (0..1).each do |k|
50
92
  expect(Ashikawa::Core::Collection).to receive(:new)
@@ -57,7 +99,7 @@ describe Ashikawa::Core::Database do
57
99
  it 'should fetch all available non-system collections' do
58
100
  expect(connection).to receive(:send_request)
59
101
  .with('collection')
60
- .and_return { server_response('collections/all') }
102
+ .and_return(server_response('collections/all'))
61
103
 
62
104
  expect(Ashikawa::Core::Collection).to receive(:new)
63
105
  .exactly(5).times
@@ -65,10 +107,19 @@ describe Ashikawa::Core::Database do
65
107
  expect(subject.system_collections.length).to eq(5)
66
108
  end
67
109
 
110
+ it 'should truncate all documents in all collections' do
111
+ collection = double('Collection')
112
+ allow(subject).to receive(:collections)
113
+ .and_return([collection])
114
+ expect(collection).to receive(:truncate)
115
+
116
+ subject.truncate
117
+ end
118
+
68
119
  it 'should create a non volatile collection by default' do
69
120
  expect(connection).to receive(:send_request)
70
121
  .with('collection', post: { name: 'volatile_collection' })
71
- .and_return { raw_collection }
122
+ .and_return(raw_collection)
72
123
 
73
124
  expect(Ashikawa::Core::Collection).to receive(:new)
74
125
  .with(subject, raw_collection)
@@ -79,7 +130,7 @@ describe Ashikawa::Core::Database do
79
130
  it 'should create a volatile collection when asked' do
80
131
  expect(connection).to receive(:send_request)
81
132
  .with('collection', post: { name: 'volatile_collection', isVolatile: true })
82
- .and_return { |path| raw_collection }
133
+ .and_return(raw_collection)
83
134
 
84
135
  expect(Ashikawa::Core::Collection).to receive(:new)
85
136
  .with(subject, raw_collection)
@@ -112,7 +163,7 @@ describe Ashikawa::Core::Database do
112
163
  it 'should create an edge collection when asked' do
113
164
  expect(connection).to receive(:send_request)
114
165
  .with('collection', post: { name: 'volatile_collection', type: 3 })
115
- .and_return { |path| raw_collection }
166
+ .and_return(raw_collection)
116
167
 
117
168
  expect(Ashikawa::Core::Collection).to receive(:new)
118
169
  .with(subject, raw_collection)
@@ -123,7 +174,7 @@ describe Ashikawa::Core::Database do
123
174
  it 'should fetch a single collection if it exists' do
124
175
  expect(connection).to receive(:send_request)
125
176
  .with('collection/60768679')
126
- .and_return { |path| raw_collection }
177
+ .and_return(raw_collection)
127
178
 
128
179
  expect(Ashikawa::Core::Collection).to receive(:new)
129
180
  .with(subject, raw_collection)
@@ -134,7 +185,7 @@ describe Ashikawa::Core::Database do
134
185
  it 'should fetch a single collection with the array syntax' do
135
186
  expect(connection).to receive(:send_request)
136
187
  .with('collection/60768679')
137
- .and_return { |path| raw_collection }
188
+ .and_return(raw_collection)
138
189
 
139
190
  expect(Ashikawa::Core::Collection).to receive(:new)
140
191
  .with(subject, raw_collection)
@@ -87,9 +87,9 @@ describe Ashikawa::Core::Document do
87
87
  end
88
88
 
89
89
  it 'should be refreshable' do
90
- expect(database).to receive(:send_request).with(path, {}).and_return {
91
- { 'name' => 'Jeff' }
92
- }
90
+ expect(database).to receive(:send_request)
91
+ .with(path, {})
92
+ .and_return({ 'name' => 'Jeff' })
93
93
 
94
94
  refreshed_subject = subject.refresh!
95
95
  expect(refreshed_subject).to eq(subject)
@@ -21,7 +21,11 @@ describe Ashikawa::Core::ClientError do
21
21
  end
22
22
 
23
23
  describe Ashikawa::Core::BadSyntax do
24
- its(:to_s) { should include 'syntax' }
24
+ let(:error_message) { 'foo' }
25
+ let(:bad_syntax) { Ashikawa::Core::BadSyntax.new(error_message) }
26
+ it 'accepts an error message to be included in to_s' do
27
+ expect(bad_syntax.to_s).to include error_message
28
+ end
25
29
  end
26
30
 
27
31
  describe Ashikawa::Core::AuthenticationFailed do
@@ -29,7 +29,12 @@ describe Ashikawa::Core::Index do
29
29
 
30
30
  its(:id) { should be(id) }
31
31
  its(:type) { should be(type_as_sym) }
32
- its(:on) { should include(field_as_sym) }
32
+
33
+ it 'should know which fields it is on' do
34
+ skip 'Currently not working on Rubinius'
35
+ expect(subject).to include(field_as_sym)
36
+ end
37
+
33
38
  its(:unique) { should be(unique) }
34
39
 
35
40
  it 'should be deletable' do
@@ -22,7 +22,7 @@ describe Ashikawa::Core::Query do
22
22
  it 'should list all documents' do
23
23
  expect(collection).to receive(:send_request)
24
24
  .with('simple/all', put: { 'collection' => name })
25
- .and_return { server_response('simple-queries/all') }
25
+ .and_return(server_response('simple-queries/all'))
26
26
  expect(Ashikawa::Core::Cursor).to receive(:new)
27
27
 
28
28
  subject.all
@@ -31,7 +31,7 @@ describe Ashikawa::Core::Query do
31
31
  it 'should be able to limit the number of documents' do
32
32
  expect(collection).to receive(:send_request)
33
33
  .with('simple/all', put: { 'collection' => name, 'limit' => limit })
34
- .and_return { server_response('simple-queries/all_skip') }
34
+ .and_return(server_response('simple-queries/all_skip'))
35
35
  expect(Ashikawa::Core::Cursor).to receive(:new)
36
36
 
37
37
  subject.all(limit: limit)
@@ -40,7 +40,7 @@ describe Ashikawa::Core::Query do
40
40
  it 'should be able to skip documents' do
41
41
  expect(collection).to receive(:send_request)
42
42
  .with('simple/all', put: { 'collection' => name, 'skip' => skip })
43
- .and_return { server_response('simple-queries/all_limit') }
43
+ .and_return(server_response('simple-queries/all_limit'))
44
44
  expect(Ashikawa::Core::Cursor).to receive(:new)
45
45
 
46
46
  subject.all(skip: skip)
@@ -48,52 +48,52 @@ describe Ashikawa::Core::Query do
48
48
  end
49
49
 
50
50
  describe 'first by example' do
51
- let(:example) { double }
51
+ let(:example_document) { double }
52
52
  let(:response) { server_response('simple-queries/example') }
53
53
 
54
54
  it 'should find exactly one fitting document' do
55
55
  allow(collection).to receive(:database)
56
56
  .and_return(double)
57
57
  expect(collection).to receive(:send_request)
58
- .with('simple/first-example', put: { 'collection' => name, 'example' => example })
58
+ .with('simple/first-example', put: { 'collection' => name, 'example' => example_document })
59
59
  .and_return(response)
60
60
  expect(Ashikawa::Core::Document).to receive(:new)
61
61
 
62
- subject.first_example(example)
62
+ subject.first_example(example_document)
63
63
  end
64
64
  end
65
65
 
66
66
  describe 'all by example' do
67
- let(:example) { { hello: 'world' } }
67
+ let(:example_document) { { hello: 'world' } }
68
68
  let(:response) { server_response('simple-queries/example') }
69
69
  let(:limit) { double }
70
70
  let(:skip) { double }
71
71
 
72
72
  it 'should find all fitting documents' do
73
73
  expect(collection).to receive(:send_request)
74
- .with('simple/by-example', put: { 'collection' => name, 'example' => example })
74
+ .with('simple/by-example', put: { 'collection' => name, 'example' => example_document })
75
75
  .and_return(response)
76
76
  expect(Ashikawa::Core::Cursor).to receive(:new)
77
77
 
78
- subject.by_example(example)
78
+ subject.by_example(example_document)
79
79
  end
80
80
 
81
81
  it 'should be able to limit the number of documents' do
82
82
  expect(collection).to receive(:send_request)
83
- .with('simple/by-example', put: { 'collection' => name, 'limit' => limit, 'example' => example })
83
+ .with('simple/by-example', put: { 'collection' => name, 'limit' => limit, 'example' => example_document })
84
84
  .and_return(response)
85
85
  expect(Ashikawa::Core::Cursor).to receive(:new)
86
86
 
87
- subject.by_example(example, limit: limit)
87
+ subject.by_example(example_document, limit: limit)
88
88
  end
89
89
 
90
90
  it 'should be able to skip documents' do
91
91
  expect(collection).to receive(:send_request)
92
- .with('simple/by-example', put: { 'collection' => name, 'skip' => skip, 'example' => example })
92
+ .with('simple/by-example', put: { 'collection' => name, 'skip' => skip, 'example' => example_document })
93
93
  .and_return(response)
94
94
  expect(Ashikawa::Core::Cursor).to receive(:new)
95
95
 
96
- subject.by_example(example, skip: skip)
96
+ subject.by_example(example_document, skip: skip)
97
97
  end
98
98
  end
99
99
 
@@ -112,7 +112,7 @@ describe Ashikawa::Core::Query do
112
112
  it 'should find documents based on latitude/longitude' do
113
113
  expect(collection).to receive(:send_request)
114
114
  .with('simple/near', put: arguments)
115
- .and_return { response }
115
+ .and_return(response)
116
116
  expect(Ashikawa::Core::Cursor).to receive(:new)
117
117
 
118
118
  subject.near(latitude: latitude, longitude: longitude)
@@ -136,7 +136,7 @@ describe Ashikawa::Core::Query do
136
136
  it 'should look for documents based on latidude/longitude' do
137
137
  expect(collection).to receive(:send_request)
138
138
  .with('simple/within' , put: arguments)
139
- .and_return { response }
139
+ .and_return(response)
140
140
  expect(Ashikawa::Core::Cursor).to receive(:new)
141
141
 
142
142
  subject.within(latitude: latitude, longitude: longitude, radius: radius)
@@ -162,7 +162,7 @@ describe Ashikawa::Core::Query do
162
162
  it 'should look for documents with an attribute in that range' do
163
163
  expect(collection).to receive(:send_request)
164
164
  .with('simple/range' , put: arguments)
165
- .and_return { response }
165
+ .and_return(response)
166
166
  expect(Ashikawa::Core::Cursor).to receive(:new)
167
167
 
168
168
  subject.in_range(attribute: attribute, left: left, right: right, closed: closed)
@@ -194,12 +194,22 @@ describe Ashikawa::Core::Query do
194
194
  subject.execute(query, count: count, batch_size: batch_size)
195
195
  end
196
196
 
197
+ it 'passes bound variables to the server' do
198
+ allow(collection).to receive(:database)
199
+ .and_return(double)
200
+ expect(collection).to receive(:send_request)
201
+ .with('cursor', post: { 'bindVars' => { 'foo' => 'bar' }, 'query' => query })
202
+ .and_return(response)
203
+
204
+ subject.execute(query, bind_vars: { 'foo' => 'bar' })
205
+ end
206
+
197
207
  it 'should return true when asked if a valid query is valid' do
198
208
  expect(collection).to receive(:send_request)
199
209
  .with('query', post: { 'query' => query })
200
- .and_return { server_response('query/valid') }
210
+ .and_return(server_response('query/valid'))
201
211
 
202
- expect(subject.valid?(query)).to be_true
212
+ expect(subject.valid?(query)).to be_truthy
203
213
  end
204
214
 
205
215
  it 'should return false when asked if an invalid query is valid' do
@@ -208,7 +218,7 @@ describe Ashikawa::Core::Query do
208
218
  expect(collection).to receive(:send_request)
209
219
  .with('query', post: { 'query' => query })
210
220
 
211
- expect(subject.valid?(query)).to be_false
221
+ expect(subject.valid?(query)).to be_falsey
212
222
  end
213
223
  end
214
224
  end
@@ -249,9 +259,9 @@ describe Ashikawa::Core::Query do
249
259
  it 'should return true when asked if a valid query is valid' do
250
260
  expect(database).to receive(:send_request)
251
261
  .with('query', post: { 'query' => query })
252
- .and_return { valid_response }
262
+ .and_return(valid_response)
253
263
 
254
- expect(subject.valid?(query)).to be_true
264
+ expect(subject.valid?(query)).to be_truthy
255
265
  end
256
266
 
257
267
  it 'should return false when asked if an invalid query is valid' do
@@ -259,7 +269,7 @@ describe Ashikawa::Core::Query do
259
269
  .with('query', post: { 'query' => query })
260
270
  .and_raise(Ashikawa::Core::BadSyntax)
261
271
 
262
- expect(subject.valid?(query)).to be_false
272
+ expect(subject.valid?(query)).to be_falsey
263
273
  end
264
274
  end
265
275
  end