fauna 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,8 +10,7 @@ RSpec.describe Fauna::Query do
10
10
  create ref('indexes'), name: 'query_by_y', source: @test_class, terms: [{ path: 'data.y' }]
11
11
  end
12
12
 
13
- wait_for_active(index_x[:ref])
14
- wait_for_active(index_y[:ref])
13
+ wait_for_index(index_x[:ref], index_y[:ref])
15
14
 
16
15
  @test_by_x = index_x[:ref]
17
16
  @test_by_y = index_y[:ref]
@@ -41,15 +40,37 @@ RSpec.describe Fauna::Query do
41
40
  end
42
41
 
43
42
  describe Fauna::Query::Expr do
44
- it 'converts to string' do
45
- expr = Fauna::Query::Expr.new(
46
- add: Fauna::Query::Expr.new(
47
- [1, Fauna::Query::Expr.new(divide: Fauna::Query::Expr.new([4, 2]))]
43
+ describe '#to_s' do
44
+ it 'converts to string' do
45
+ expr = Fauna::Query::Expr.new(
46
+ add: Fauna::Query::Expr.new(
47
+ [1, Fauna::Query::Expr.new(divide: Fauna::Query::Expr.new([4, 2]))]
48
+ )
48
49
  )
49
- )
50
- as_string = 'Expr({:add=>Expr([1, Expr({:divide=>Expr([4, 2])})])})'
50
+ as_string = 'Expr({:add=>Expr([1, Expr({:divide=>Expr([4, 2])})])})'
51
51
 
52
- expect(expr.to_s).to eq(as_string)
52
+ expect(expr.to_s).to eq(as_string)
53
+ end
54
+ end
55
+
56
+ describe '#==' do
57
+ it 'equals identical expression' do
58
+ expr1 = Fauna::Query::Expr.new(add: Fauna::Query::Expr.new([1, 2]))
59
+ expr2 = Fauna::Query::Expr.new(add: Fauna::Query::Expr.new([1, 2]))
60
+
61
+ expect(expr1).to eq(expr2)
62
+ end
63
+
64
+ it 'does not equal different expression' do
65
+ expr1 = Fauna::Query::Expr.new(add: Fauna::Query::Expr.new([1, 2]))
66
+ expr2 = Fauna::Query::Expr.new(
67
+ add: Fauna::Query::Expr.new(
68
+ [1, Fauna::Query::Expr.new(divide: Fauna::Query::Expr.new([4, 2]))]
69
+ )
70
+ )
71
+
72
+ expect(expr1).not_to eq(expr2)
73
+ end
53
74
  end
54
75
  end
55
76
 
@@ -84,9 +105,14 @@ RSpec.describe Fauna::Query do
84
105
  end
85
106
 
86
107
  describe '#ref' do
87
- it 'creates a ref' do
88
- ref = random_ref
89
- expect(Fauna::Query.ref(ref)).to eq(Fauna::Ref.new(ref))
108
+ it 'returns a ref from a string' do
109
+ str = random_ref_string
110
+ expect(Fauna::Query.ref(str)).to eq(Fauna::Ref.new(str))
111
+ end
112
+
113
+ it 'constructs a ref' do
114
+ expect(client.query { ref(@test_class, '123') }).to eq(Fauna::Ref.new('classes/query_test/123'))
115
+ expect(client.query { ref(@test_class, next_id) }.value).to match(%r{^classes/query_test/\d+$})
90
116
  end
91
117
  end
92
118
 
@@ -424,7 +450,7 @@ RSpec.describe Fauna::Query do
424
450
  over_z = client.query do
425
451
  create ref('indexes'), name: 'query_over_z', source: @test_class, values: [{ path: 'data.z' }]
426
452
  end
427
- wait_for_active(over_z[:ref])
453
+ wait_for_index(over_z[:ref])
428
454
  @test_over_z = over_z[:ref]
429
455
 
430
456
  @refs = []
@@ -470,6 +496,17 @@ RSpec.describe Fauna::Query do
470
496
  expect(get_set_data(set)).to eq(@assoc_refs)
471
497
  end
472
498
  end
499
+
500
+ context 'with index' do
501
+ it 'performs join' do
502
+ source = Fauna::Query.match(@test_by_x, @x_value)
503
+ expect(get_set_data(source)).to eq(@join_refs)
504
+
505
+ # Get associated refs
506
+ set = Fauna::Query.expr { join(source, @test_by_y) }
507
+ expect(get_set_data(set)).to eq(@assoc_refs)
508
+ end
509
+ end
473
510
  end
474
511
 
475
512
  describe 'authentication' do
@@ -550,6 +587,12 @@ RSpec.describe Fauna::Query do
550
587
  end
551
588
  end
552
589
 
590
+ describe '#next_id' do
591
+ it 'gets a new id' do
592
+ expect(client.query { next_id }).to be_a(String)
593
+ end
594
+ end
595
+
553
596
  describe '#equals' do
554
597
  it 'performs equals' do
555
598
  expect(client.query { equals(1, 1, 1) }).to be(true)
@@ -8,32 +8,12 @@ RSpec.describe Fauna::Ref do
8
8
  name = random_string
9
9
  expect(Fauna::Ref.new("classes/#{name}").value).to eq("classes/#{name}")
10
10
  end
11
-
12
- it 'creates from arguments' do
13
- name = random_string
14
- id = random_number
15
-
16
- expect(Fauna::Ref.new('classes', name).value).to eq("classes/#{name}")
17
- expect(Fauna::Ref.new('classes', name, id).value).to eq("classes/#{name}/#{id}")
18
- end
19
-
20
- it 'creates from other refs' do
21
- ref = Fauna::Ref.new('classes')
22
- name = random_string
23
- id = random_number
24
-
25
- class_ref = Fauna::Ref.new(ref, name)
26
-
27
- expect(class_ref.value).to eq("classes/#{name}")
28
- expect(Fauna::Ref.new(class_ref, id).value).to eq("classes/#{name}/#{id}")
29
- expect(Fauna::Ref.new(ref, name, id).value).to eq("classes/#{name}/#{id}")
30
- end
31
11
  end
32
12
 
33
13
  describe '#id' do
34
14
  context 'with multiple elements' do
35
15
  it 'returns id portion' do
36
- expect(Fauna::Ref.new('classes', 'test').id).to eq('test')
16
+ expect(Fauna::Ref.new('classes/test').id).to eq('test')
37
17
  end
38
18
  end
39
19
 
@@ -45,13 +25,19 @@ RSpec.describe Fauna::Ref do
45
25
  end
46
26
 
47
27
  describe '#to_class' do
48
- context 'with multiple elements' do
28
+ context 'with three elements' do
49
29
  it 'returns class portion' do
50
- expect(Fauna::Ref.new('classes', 'test').to_class).to eq(Fauna::Ref.new('classes'))
30
+ expect(Fauna::Ref.new('classes/test/1234').to_class).to eq(Fauna::Ref.new('classes/test'))
51
31
  end
52
32
  end
53
33
 
54
- context 'with single element' do
34
+ context 'with two elements' do
35
+ it 'returns class portion' do
36
+ expect(Fauna::Ref.new('classes/test').to_class).to eq(Fauna::Ref.new('classes'))
37
+ end
38
+ end
39
+
40
+ context 'with one element' do
55
41
  it 'returns class portion' do
56
42
  expect(Fauna::Ref.new('classes').to_class).to eq(Fauna::Ref.new('classes'))
57
43
  end
@@ -1,20 +1,20 @@
1
1
  RSpec.describe Fauna::SetRef do
2
2
  describe '#==' do
3
3
  it 'equals same set' do
4
- data = { match: random_ref, terms: random_string }
4
+ data = { match: random_ref_string, terms: random_string }
5
5
  set = Fauna::SetRef.new(data)
6
6
 
7
7
  expect(set).to eq(Fauna::SetRef.new(data))
8
8
  end
9
9
 
10
10
  it 'does not equal different set' do
11
- set = Fauna::SetRef.new(match: random_ref, terms: random_string)
11
+ set = Fauna::SetRef.new(match: random_ref_string, terms: random_string)
12
12
 
13
- expect(set).not_to eq(Fauna::SetRef.new(match: random_ref, terms: random_string))
13
+ expect(set).not_to eq(Fauna::SetRef.new(match: random_ref_string, terms: random_string))
14
14
  end
15
15
 
16
16
  it 'does not equal other type' do
17
- data = { match: random_ref, terms: random_string }
17
+ data = { match: random_ref_string, terms: random_string }
18
18
  set = Fauna::SetRef.new(data)
19
19
 
20
20
  expect(set).not_to eq(data)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fauna
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fauna, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-16 00:00:00.000000000 Z
11
+ date: 2016-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -58,29 +58,29 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.35.0
61
+ version: 0.38.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.35.0
68
+ version: 0.38.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: coveralls
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.8.10
75
+ version: 0.8.13
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.8.10
83
- description: Ruby client for the Fauna distributed database.
82
+ version: 0.8.13
83
+ description: Ruby driver for FaunaDB.
84
84
  email: priority@faunadb.com
85
85
  executables: []
86
86
  extensions: []
@@ -102,6 +102,7 @@ files:
102
102
  - lib/fauna/errors.rb
103
103
  - lib/fauna/json.rb
104
104
  - lib/fauna/objects.rb
105
+ - lib/fauna/page.rb
105
106
  - lib/fauna/query.rb
106
107
  - lib/fauna/request_result.rb
107
108
  - lib/fauna/util.rb
@@ -112,6 +113,7 @@ files:
112
113
  - spec/errors_spec.rb
113
114
  - spec/fauna_helper.rb
114
115
  - spec/json_spec.rb
116
+ - spec/page_spec.rb
115
117
  - spec/query_spec.rb
116
118
  - spec/ref_spec.rb
117
119
  - spec/setref_spec.rb
@@ -145,11 +147,12 @@ rubyforge_project:
145
147
  rubygems_version: 2.4.5.1
146
148
  signing_key:
147
149
  specification_version: 4
148
- summary: FaunaDB Ruby client
150
+ summary: FaunaDB Ruby driver
149
151
  test_files:
150
152
  - spec/util_spec.rb
151
153
  - spec/context_spec.rb
152
154
  - spec/client_logger_spec.rb
155
+ - spec/page_spec.rb
153
156
  - spec/query_spec.rb
154
157
  - spec/fauna_helper.rb
155
158
  - spec/client_spec.rb