perpetuity-postgres 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/lib/perpetuity/postgres/connection.rb +12 -0
  4. data/lib/perpetuity/postgres/version.rb +1 -1
  5. data/perpetuity-postgres.gemspec +1 -1
  6. data/spec/perpetuity/postgres/boolean_value_spec.rb +2 -2
  7. data/spec/perpetuity/postgres/connection_pool_spec.rb +3 -4
  8. data/spec/perpetuity/postgres/connection_spec.rb +6 -6
  9. data/spec/perpetuity/postgres/date_value_spec.rb +3 -3
  10. data/spec/perpetuity/postgres/expression_spec.rb +1 -1
  11. data/spec/perpetuity/postgres/index_collection_spec.rb +4 -4
  12. data/spec/perpetuity/postgres/index_spec.rb +13 -13
  13. data/spec/perpetuity/postgres/json_array_spec.rb +7 -7
  14. data/spec/perpetuity/postgres/json_hash_spec.rb +10 -10
  15. data/spec/perpetuity/postgres/json_string_value_spec.rb +3 -3
  16. data/spec/perpetuity/postgres/negated_query_spec.rb +8 -8
  17. data/spec/perpetuity/postgres/null_value_spec.rb +1 -1
  18. data/spec/perpetuity/postgres/numeric_value_spec.rb +1 -1
  19. data/spec/perpetuity/postgres/query_attribute_spec.rb +15 -15
  20. data/spec/perpetuity/postgres/query_expression_spec.rb +19 -19
  21. data/spec/perpetuity/postgres/query_intersection_spec.rb +3 -3
  22. data/spec/perpetuity/postgres/query_spec.rb +3 -3
  23. data/spec/perpetuity/postgres/query_union_spec.rb +3 -3
  24. data/spec/perpetuity/postgres/serialized_data_spec.rb +14 -14
  25. data/spec/perpetuity/postgres/serializer_spec.rb +23 -23
  26. data/spec/perpetuity/postgres/sql_function_spec.rb +2 -2
  27. data/spec/perpetuity/postgres/sql_select_spec.rb +11 -11
  28. data/spec/perpetuity/postgres/sql_update_spec.rb +2 -2
  29. data/spec/perpetuity/postgres/sql_value_spec.rb +14 -14
  30. data/spec/perpetuity/postgres/table/attribute_spec.rb +17 -17
  31. data/spec/perpetuity/postgres/table_name_spec.rb +2 -2
  32. data/spec/perpetuity/postgres/table_spec.rb +6 -6
  33. data/spec/perpetuity/postgres/text_value_spec.rb +2 -2
  34. data/spec/perpetuity/postgres/timestamp_value_spec.rb +4 -4
  35. data/spec/perpetuity/postgres/value_with_attribute_spec.rb +6 -6
  36. data/spec/perpetuity/postgres_spec.rb +38 -38
  37. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 131881bc7b24a361b04326b0fac2699ca1ca2c22
4
- data.tar.gz: 57dc7bd53e485500524439604ceaa517f5990215
3
+ metadata.gz: dbfd7bfbff611c846132965cc13c105ac722f469
4
+ data.tar.gz: 70179a20ab781629f0f1c56e6639104476e5fbe1
5
5
  SHA512:
6
- metadata.gz: e1c978801cc9d1a5c4bc888c899ce27ff15166bb396ad4eb5b95212664b408e76f13afb57175220072b532b6beaeb598794c67c0f1de809cb893bad71de49e8a
7
- data.tar.gz: 5645ce0e3ebca3602b789515db6762ca0713c958dd915502dea87d8137df67f1c55b8b53bd9a632e081c55ce8ee767a12984a294a74db2992150ef48c8b32a68
6
+ metadata.gz: fbe960158dfbab549a471033e7e8219f477aa2e3f2c573c685b9eee7ac8bdbbb5d1877f7df9722fb98310f6e67186b4b6103658027f518e4173f1683b4f65d7a
7
+ data.tar.gz: c380f8f7b8cc6ccbf731dc92e58dd7995c95ac91d4629c856553fd4d672afb3133a2cbffd88220b499c675afe56d5c767d7f64cc9b5141505bbf4ca6d9f493bc
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## Version 0.0.8
2
+
3
+ - Reconnect automatically if connection is interrupted. Reconnection is tried 3x at 1-second intervals.
4
+
1
5
  ## Version 0.0.7
2
6
 
3
7
  - Allow for querying within a range: `mapper.select { |o| o.value.in (1..3) }`
@@ -43,6 +43,18 @@ module Perpetuity
43
43
 
44
44
  def execute sql
45
45
  pg_connection.exec sql
46
+ rescue PG::AdminShutdown, PG::UnableToSend => e
47
+ # server closed the connection unexpectedly
48
+ # Try to reconnect 3 times in case it's just a server restart.
49
+ unable_to_send_retries ||= 0
50
+ if unable_to_send_retries < 3
51
+ connect
52
+ unable_to_send_retries += 1
53
+ sleep 1
54
+ retry
55
+ else
56
+ raise
57
+ end
46
58
  rescue PG::UndefinedFunction => e
47
59
  if e.message =~ /uuid_generate/
48
60
  use_uuid_extension
@@ -1,5 +1,5 @@
1
1
  module Perpetuity
2
2
  class Postgres
3
- VERSION = "0.0.7"
3
+ VERSION = "0.0.8"
4
4
  end
5
5
  end
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rspec", "~> 2.0"
22
+ spec.add_development_dependency "rspec"
23
23
  spec.add_development_dependency "rake"
24
24
  spec.add_runtime_dependency "perpetuity", "~> 1.0.0"
25
25
  spec.add_runtime_dependency "pg"
@@ -4,11 +4,11 @@ module Perpetuity
4
4
  class Postgres
5
5
  describe BooleanValue do
6
6
  it 'serializes true into a Postgres true value' do
7
- BooleanValue.new(true).to_s.should == 'TRUE'
7
+ expect(BooleanValue.new(true).to_s).to be == 'TRUE'
8
8
  end
9
9
 
10
10
  it 'serializes false into a Postgres false value' do
11
- BooleanValue.new(false).to_s.should == 'FALSE'
11
+ expect(BooleanValue.new(false).to_s).to be == 'FALSE'
12
12
  end
13
13
  end
14
14
  end
@@ -26,19 +26,18 @@ module Perpetuity
26
26
  end
27
27
 
28
28
  it 'returns the value of the block' do
29
- pool.lend_connection { 1 }.should == 1
29
+ expect(pool.lend_connection { 1 }).to be == 1
30
30
  end
31
31
  end
32
32
 
33
33
  it 'executes a given SQL statement' do
34
34
  sql = "SELECT TRUE"
35
- Connection.any_instance.should_receive(:execute)
36
- .with(sql)
35
+ expect_any_instance_of(Connection).to receive(:execute).with(sql)
37
36
  pool.execute sql
38
37
  end
39
38
 
40
39
  it 'passes the tables message to a connection' do
41
- Connection.any_instance.should_receive(:tables)
40
+ expect_any_instance_of(Connection).to receive(:tables)
42
41
  pool.tables
43
42
  end
44
43
 
@@ -7,24 +7,24 @@ module Perpetuity
7
7
 
8
8
  it 'sanitizes the options for the pg gem' do
9
9
  options = { db: 'db', username: 'user' }
10
- connection.sanitize_options(options).should == {
10
+ expect(connection.sanitize_options(options)).to be == {
11
11
  dbname: 'db',
12
12
  user: 'user'
13
13
  }
14
14
  end
15
15
 
16
16
  it 'is only activated when it is used' do
17
- connection.should_not be_active
18
- PG.stub(connect: double(exec: true))
17
+ expect(connection).not_to be_active
18
+ allow(PG).to receive(:connect) { double(exec: true) }
19
19
  connection.connect
20
- connection.should be_active
20
+ expect(connection).to be_active
21
21
  end
22
22
 
23
23
  it 'executes SQL' do
24
24
  connection.execute 'CREATE TABLE IF NOT EXISTS abcdefg (name text)'
25
- connection.tables.should include 'abcdefg'
25
+ expect(connection.tables).to include 'abcdefg'
26
26
  connection.execute 'DROP TABLE IF EXISTS abcdefg'
27
- connection.tables.should_not include 'abcdefg'
27
+ expect(connection.tables).not_to include 'abcdefg'
28
28
  end
29
29
  end
30
30
  end
@@ -5,19 +5,19 @@ module Perpetuity
5
5
  describe DateValue do
6
6
  it 'converts to a SQL string' do
7
7
  date = Date.new(2014, 8, 25)
8
- DateValue.new(date).to_s.should == "'2014-08-25'::date"
8
+ expect(DateValue.new(date).to_s).to be == "'2014-08-25'::date"
9
9
  end
10
10
 
11
11
  describe 'conversion from a SQL value string' do
12
12
  it 'converts GMT-X times' do
13
13
  actual = DateValue.from_sql('2013-12-01')
14
14
  expected = Date.new(2013, 12, 1)
15
- actual.to_date.should == expected
15
+ expect(actual.to_date).to be == expected
16
16
  end
17
17
  end
18
18
 
19
19
  it 'returns its wrapped value' do
20
- DateValue.new(:foo).value.should == :foo
20
+ expect(DateValue.new(:foo).value).to be == :foo
21
21
  end
22
22
  end
23
23
  end
@@ -6,7 +6,7 @@ module Perpetuity
6
6
  let(:expression) { Expression.new('uuid_generate_v4()') }
7
7
 
8
8
  it 'passes the expression straight into SQL' do
9
- expression.to_sql.should == 'uuid_generate_v4()'
9
+ expect(expression.to_sql).to be == 'uuid_generate_v4()'
10
10
  end
11
11
  end
12
12
  end
@@ -7,22 +7,22 @@ module Perpetuity
7
7
  let(:indexes) { IndexCollection.new(Object) }
8
8
 
9
9
  it 'knows which table it is indexing' do
10
- indexes.table.should == 'Object'
10
+ expect(indexes.table).to be == 'Object'
11
11
  end
12
12
 
13
13
  it 'iterates over its indexes' do
14
14
  indexes << 1
15
- indexes.map { |index| index.to_s }.should include '1'
15
+ expect(indexes.map { |index| index.to_s }).to include '1'
16
16
  end
17
17
 
18
18
  it 'converts to an array' do
19
- indexes.to_ary.should == []
19
+ expect(indexes.to_ary).to be == []
20
20
  end
21
21
 
22
22
  it 'removes indexes based on a block' do
23
23
  indexes << double('Index', name: 'lol')
24
24
  indexes.reject! { |index| index.name == 'lol' }
25
- indexes.map(&:name).should_not include 'lol'
25
+ expect(indexes.map(&:name)).not_to include 'lol'
26
26
  end
27
27
  end
28
28
  end
@@ -12,11 +12,11 @@ module Perpetuity
12
12
  }
13
13
 
14
14
  index = Index.from_sql(index_hash)
15
- index.attribute_names.should == ['id', 'name']
16
- index.name.should == 'Object_id_name_index'
17
- index.table.should == 'Object'
18
- index.should be_unique
19
- index.should be_active
15
+ expect(index.attribute_names).to be == ['id', 'name']
16
+ expect(index.name).to be == 'Object_id_name_index'
17
+ expect(index.table).to be == 'Object'
18
+ expect(index).to be_unique
19
+ expect(index).to be_active
20
20
  end
21
21
 
22
22
  it 'sets itself as active' do
@@ -24,9 +24,9 @@ module Perpetuity
24
24
  name: 'Table',
25
25
  unique: false)
26
26
 
27
- index.should_not be_active
27
+ expect(index).not_to be_active
28
28
  index.activate!
29
- index.should be_active
29
+ expect(index).to be_active
30
30
  end
31
31
 
32
32
  describe 'equality' do
@@ -41,7 +41,7 @@ module Perpetuity
41
41
 
42
42
  it 'is equal to an index with identical state' do
43
43
  new_index = index.dup
44
- new_index.should == index
44
+ expect(new_index).to be == index
45
45
  end
46
46
 
47
47
  it 'is not equal to an index with different attributes' do
@@ -49,14 +49,14 @@ module Perpetuity
49
49
  name: name,
50
50
  unique: unique)
51
51
 
52
- new_index.should_not == index
52
+ expect(new_index).not_to be == index
53
53
  end
54
54
 
55
55
  it 'is equal to an index with stringified attributes' do
56
56
  new_index = Index.new(attributes: attributes.map(&:to_s),
57
57
  name: name,
58
58
  unique: unique)
59
- new_index.should == index
59
+ expect(new_index).to be == index
60
60
  end
61
61
 
62
62
  it 'is not equal to an index with another name' do
@@ -64,18 +64,18 @@ module Perpetuity
64
64
  name: 'NotObject',
65
65
  unique: unique)
66
66
 
67
- new_index.should_not == index
67
+ expect(new_index).not_to be == index
68
68
  end
69
69
 
70
70
  it 'is not equal to an index with opposite uniqueness' do
71
71
  new_index = Index.new(attributes: attributes,
72
72
  name: name,
73
73
  unique: !unique)
74
- new_index.should_not == index
74
+ expect(new_index).not_to be == index
75
75
  end
76
76
 
77
77
  it 'is not equal to things that are not indexes' do
78
- index.should_not == 'lol'
78
+ expect(index).not_to be == 'lol'
79
79
  end
80
80
  end
81
81
  end
@@ -4,31 +4,31 @@ module Perpetuity
4
4
  class Postgres
5
5
  describe JSONArray do
6
6
  it 'serializes empty arrays' do
7
- JSONArray.new([]).to_s.should == "'[]'"
7
+ expect(JSONArray.new([]).to_s).to be == "'[]'"
8
8
  end
9
9
 
10
10
  it 'serializes arrays of numeric values' do
11
- JSONArray.new([1,2,3]).to_s.should == "'[1,2,3]'"
11
+ expect(JSONArray.new([1,2,3]).to_s).to be == "'[1,2,3]'"
12
12
  end
13
13
 
14
14
  it 'serializes arrays of strings' do
15
- JSONArray.new(%w(foo bar baz)).to_s.should == %q{'["foo","bar","baz"]'}
15
+ expect(JSONArray.new(%w(foo bar baz)).to_s).to be == %q{'["foo","bar","baz"]'}
16
16
  end
17
17
 
18
18
  it 'serializes arrays of hashes' do
19
- JSONArray.new([{a: 1}, {b: 2}]).to_s.should == %q{'[{"a":1},{"b":2}]'}
19
+ expect(JSONArray.new([{a: 1}, {b: 2}]).to_s).to be == %q{'[{"a":1},{"b":2}]'}
20
20
  end
21
21
 
22
22
  it 'serializes arrays of JSONHashes' do
23
- JSONArray.new([JSONHash.new(a: 1)]).to_s.should == %q{'[{"a":1}]'}
23
+ expect(JSONArray.new([JSONHash.new(a: 1)]).to_s).to be == %q{'[{"a":1}]'}
24
24
  end
25
25
 
26
26
  it 'serializes arrays of arrays' do
27
- JSONArray.new([[1], ['foo']]).to_s.should == %q{'[[1],["foo"]]'}
27
+ expect(JSONArray.new([[1], ['foo']]).to_s).to be == %q{'[[1],["foo"]]'}
28
28
  end
29
29
 
30
30
  it 'serializes elements of arrays' do
31
- JSONArray.new([1,'a']).to_s.should == %q{'[1,"a"]'}
31
+ expect(JSONArray.new([1,'a']).to_s).to be == %q{'[1,"a"]'}
32
32
  end
33
33
  end
34
34
  end
@@ -4,44 +4,44 @@ module Perpetuity
4
4
  class Postgres
5
5
  describe JSONHash do
6
6
  it 'serializes empty hashes' do
7
- JSONHash.new({}).to_s.should == "'{}'"
7
+ expect(JSONHash.new({}).to_s).to be == "'{}'"
8
8
  end
9
9
 
10
10
  it 'serializes hashes with string elements' do
11
- JSONHash.new({a: 'b'}).to_s.should == %q{'{"a":"b"}'}
11
+ expect(JSONHash.new({a: 'b'}).to_s).to be == %q{'{"a":"b"}'}
12
12
  end
13
13
 
14
14
  it 'serializes hashes with numeric elements' do
15
- JSONHash.new({a: 1}).to_s.should == %q{'{"a":1}'}
15
+ expect(JSONHash.new({a: 1}).to_s).to be == %q{'{"a":1}'}
16
16
  end
17
17
 
18
18
  it 'serializes hashes with boolean elements' do
19
- JSONHash.new({a: true, b: false}).to_s.should == %q('{"a":true,"b":false}')
19
+ expect(JSONHash.new({a: true, b: false}).to_s).to be == %q('{"a":true,"b":false}')
20
20
  end
21
21
 
22
22
  it 'serializes nil values' do
23
- JSONHash.new({a: nil}).to_s.should == %q('{"a":null}')
23
+ expect(JSONHash.new({a: nil}).to_s).to be == %q('{"a":null}')
24
24
  end
25
25
 
26
26
  it 'does not surround the an inner serialized value with quotes' do
27
- JSONHash.new({a: 1}, :inner).to_s.should == %q[{"a":1}]
27
+ expect(JSONHash.new({a: 1}, :inner).to_s).to be == %q[{"a":1}]
28
28
  end
29
29
 
30
30
  it 'serializes hashes with multiple entries' do
31
- JSONHash.new({a: 1, b: 'c'}).to_s.should == %q{'{"a":1,"b":"c"}'}
31
+ expect(JSONHash.new({a: 1, b: 'c'}).to_s).to be == %q{'{"a":1,"b":"c"}'}
32
32
  end
33
33
 
34
34
  it 'serializes a hash with array values' do
35
- JSONHash.new({foo: ['bar', 'baz', 'quux']}).to_s.should ==
35
+ expect(JSONHash.new({foo: ['bar', 'baz', 'quux']}).to_s).to be ==
36
36
  %q{'{"foo":["bar","baz","quux"]}'}
37
37
  end
38
38
 
39
39
  it 'converts back to a hash' do
40
- JSONHash.new({a: 1}).to_hash.should == { a: 1 }
40
+ expect(JSONHash.new({a: 1}).to_hash).to be == { a: 1 }
41
41
  end
42
42
 
43
43
  it 'is equal to an identical hash' do
44
- JSONHash.new(a: 1).should == JSONHash.new(a: 1)
44
+ expect(JSONHash.new(a: 1)).to be == JSONHash.new(a: 1)
45
45
  end
46
46
  end
47
47
  end
@@ -4,15 +4,15 @@ module Perpetuity
4
4
  class Postgres
5
5
  describe JSONStringValue do
6
6
  it 'serializes into a JSON string value' do
7
- JSONStringValue.new('Jamie').to_s.should == '"Jamie"'
7
+ expect(JSONStringValue.new('Jamie').to_s).to be == '"Jamie"'
8
8
  end
9
9
 
10
10
  it 'converts symbols into strings' do
11
- JSONStringValue.new(:foo).to_s.should == '"foo"'
11
+ expect(JSONStringValue.new(:foo).to_s).to be == '"foo"'
12
12
  end
13
13
 
14
14
  it 'escapes quotes' do
15
- JSONStringValue.new('Anakin "Darth Vader" Skywalker').to_s.should ==
15
+ expect(JSONStringValue.new('Anakin "Darth Vader" Skywalker').to_s).to be ==
16
16
  '"Anakin \\"Darth Vader\\" Skywalker"'
17
17
  end
18
18
  end
@@ -4,35 +4,35 @@ module Perpetuity
4
4
  class Postgres
5
5
  describe NegatedQuery do
6
6
  it 'negates equality' do
7
- NegatedQuery.new { |o| o.name == 'foo' }.to_db.should == "NOT (name = 'foo')"
7
+ expect(NegatedQuery.new { |o| o.name == 'foo' }.to_db).to be == "NOT (name = 'foo')"
8
8
  end
9
9
 
10
10
  it 'negates regex matching' do
11
- NegatedQuery.new { |o| o.name =~ /foo/ }.to_db.should == "NOT (name ~ 'foo')"
11
+ expect(NegatedQuery.new { |o| o.name =~ /foo/ }.to_db).to be == "NOT (name ~ 'foo')"
12
12
  end
13
13
 
14
14
  it 'negates case-insensitive regex matching' do
15
- NegatedQuery.new { |o| o.name =~ /foo/i }.to_db.should == "NOT (name ~* 'foo')"
15
+ expect(NegatedQuery.new { |o| o.name =~ /foo/i }.to_db).to be == "NOT (name ~* 'foo')"
16
16
  end
17
17
 
18
18
  it 'negates inequality' do
19
- NegatedQuery.new { |o| o.name != /foo/i }.to_db.should == "NOT (name != 'foo')"
19
+ expect(NegatedQuery.new { |o| o.name != /foo/i }.to_db).to be == "NOT (name != 'foo')"
20
20
  end
21
21
 
22
22
  it 'negates greater-than' do
23
- NegatedQuery.new { |o| o.age > 1 }.to_db.should == "NOT (age > 1)"
23
+ expect(NegatedQuery.new { |o| o.age > 1 }.to_db).to be == "NOT (age > 1)"
24
24
  end
25
25
 
26
26
  it 'negates greater-than-or-equal' do
27
- NegatedQuery.new { |o| o.age >= 1 }.to_db.should == "NOT (age >= 1)"
27
+ expect(NegatedQuery.new { |o| o.age >= 1 }.to_db).to be == "NOT (age >= 1)"
28
28
  end
29
29
 
30
30
  it 'negates less-than' do
31
- NegatedQuery.new { |o| o.age < 1 }.to_db.should == "NOT (age < 1)"
31
+ expect(NegatedQuery.new { |o| o.age < 1 }.to_db).to be == "NOT (age < 1)"
32
32
  end
33
33
 
34
34
  it 'negates less-than-or-equal' do
35
- NegatedQuery.new { |o| o.age <= 1 }.to_db.should == "NOT (age <= 1)"
35
+ expect(NegatedQuery.new { |o| o.age <= 1 }.to_db).to be == "NOT (age <= 1)"
36
36
  end
37
37
  end
38
38
  end
@@ -4,7 +4,7 @@ module Perpetuity
4
4
  class Postgres
5
5
  describe NullValue do
6
6
  it 'serializes into a Postgres NULL value' do
7
- NullValue.new.to_s.should == 'NULL'
7
+ expect(NullValue.new.to_s).to be == 'NULL'
8
8
  end
9
9
  end
10
10
  end
@@ -4,7 +4,7 @@ module Perpetuity
4
4
  class Postgres
5
5
  describe NumericValue do
6
6
  it 'serializes into a Postgres-compatible number value' do
7
- NumericValue.new(1).to_s.should == '1'
7
+ expect(NumericValue.new(1).to_s).to be == '1'
8
8
  end
9
9
  end
10
10
  end
@@ -6,62 +6,62 @@ module Perpetuity
6
6
  let(:attribute) { QueryAttribute.new :attribute_name }
7
7
 
8
8
  it 'returns its name' do
9
- attribute.name.should == :attribute_name
9
+ expect(attribute.name).to be == :attribute_name
10
10
  end
11
11
 
12
12
  it 'checks for equality' do
13
- (attribute == 1).should be_a QueryExpression
13
+ expect((attribute == 1)).to be_a QueryExpression
14
14
  end
15
15
 
16
16
  it 'checks for less than' do
17
- (attribute < 1).should be_a QueryExpression
17
+ expect((attribute < 1)).to be_a QueryExpression
18
18
  end
19
19
 
20
20
  it 'checks for <=' do
21
- (attribute <= 1).should be_a QueryExpression
21
+ expect((attribute <= 1)).to be_a QueryExpression
22
22
  end
23
23
 
24
24
  it 'checks for greater than' do
25
- (attribute > 1).should be_a QueryExpression
25
+ expect((attribute > 1)).to be_a QueryExpression
26
26
  end
27
27
 
28
28
  it 'checks for >=' do
29
- (attribute >= 1).should be_a QueryExpression
29
+ expect((attribute >= 1)).to be_a QueryExpression
30
30
  end
31
31
 
32
32
  it 'checks for inequality' do
33
- (attribute != 1).should be_a QueryExpression
33
+ expect((attribute != 1)).to be_a QueryExpression
34
34
  end
35
35
 
36
36
  it 'checks for regexp matches' do
37
- (attribute =~ /value/).should be_a QueryExpression
37
+ expect((attribute =~ /value/)).to be_a QueryExpression
38
38
  end
39
39
 
40
40
  it 'checks for inclusion' do
41
- (attribute.in [1, 2, 3]).should be_a QueryExpression
41
+ expect((attribute.in [1, 2, 3])).to be_a QueryExpression
42
42
  end
43
43
 
44
44
  it 'checks for existence' do
45
- (attribute.any?).to_db.should == 'json_array_length(attribute_name) > 0'
45
+ expect((attribute.any?).to_db).to be == 'json_array_length(attribute_name) > 0'
46
46
  end
47
47
 
48
48
  it 'checks for no existence' do
49
- (attribute.none?).to_db.should == 'json_array_length(attribute_name) = 0'
49
+ expect((attribute.none?).to_db).to be == 'json_array_length(attribute_name) = 0'
50
50
  end
51
51
 
52
52
  it 'checks for nil' do
53
- attribute.nil?.should be_a QueryExpression
53
+ expect(attribute.nil?).to be_a QueryExpression
54
54
  end
55
55
 
56
56
  it 'checks for truthiness' do
57
- attribute.to_db.should == 'attribute_name IS NOT NULL'
57
+ expect(attribute.to_db).to be == 'attribute_name IS NOT NULL'
58
58
  end
59
59
 
60
60
  describe 'nested attributes' do
61
61
  it 'checks for an id' do
62
62
  id = attribute.id
63
- id.should be_a QueryAttribute
64
- id.name.should == %q{attribute_name->'__metadata__'->>'id'}
63
+ expect(id).to be_a QueryAttribute
64
+ expect(id.name).to be == %q{attribute_name->'__metadata__'->>'id'}
65
65
  end
66
66
  end
67
67
  end