yax-fauna 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,25 @@
1
+ RSpec.describe Fauna::QueryV do
2
+ describe '#==' do
3
+ it 'equals same query' do
4
+ lambda = Fauna::Query.expr { lambda_expr([:a], add(var(:a), var(:a))) }
5
+ query = Fauna::QueryV.new(lambda)
6
+
7
+ expect(query).to eq(Fauna::QueryV.new(lambda))
8
+ end
9
+
10
+ it 'does not equal different query' do
11
+ lambda = Fauna::Query.expr { lambda_expr([:a], add(var(:a), var(:a))) }
12
+ query = Fauna::QueryV.new(lambda)
13
+
14
+ other_lambda = Fauna::Query.expr { lambda_expr([:b], multiply(var(:b), var(:b))) }
15
+ expect(query).not_to eq(Fauna::QueryV.new(other_lambda))
16
+ end
17
+
18
+ it 'does not equal other type' do
19
+ lambda = Fauna::Query.expr { lambda_expr([:a], add(var(:a), var(:a))) }
20
+ query = Fauna::QueryV.new(lambda)
21
+
22
+ expect(query).not_to eq(lambda)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,99 @@
1
+ RSpec.describe Fauna::Ref do
2
+ it 'converts to string' do
3
+ db = Fauna::Ref.new('db', Fauna::Native.databases)
4
+ expect(db.to_s).to eq('Ref(id=db,class=Ref(id=databases))')
5
+
6
+ cls = Fauna::Ref.new('cls', Fauna::Native.classes, db)
7
+ expect(cls.to_s).to eq('Ref(id=cls,class=Ref(id=classes),database=Ref(id=db,class=Ref(id=databases)))')
8
+
9
+ expect(Fauna::Ref.new('test', cls).to_s).to eq('Ref(id=test,class=Ref(id=cls,class=Ref(id=classes),database=Ref(id=db,class=Ref(id=databases))))')
10
+ end
11
+
12
+ describe '#id' do
13
+ it 'returns id portion' do
14
+ expect(Fauna::Ref.new('test', Fauna::Native.classes).id).to eq('test')
15
+ end
16
+
17
+ it 'raises error' do
18
+ expect { Fauna::Ref.new(nil) }.to raise_error(ArgumentError)
19
+ end
20
+ end
21
+
22
+ describe '#class_' do
23
+ context 'with id and user class' do
24
+ it 'returns class portion' do
25
+ expect(Fauna::Ref.new('1234', Fauna::Ref.new('test', Fauna::Native.classes)).class_).to eq(Fauna::Ref.new('test', Fauna::Native.classes))
26
+ end
27
+ end
28
+
29
+ context 'user class only' do
30
+ it 'returns class portion' do
31
+ expect(Fauna::Ref.new('test', Fauna::Native.classes).class_).to eq(Fauna::Native.classes)
32
+ end
33
+ end
34
+
35
+ context 'without id and user class' do
36
+ it 'does not return class portion' do
37
+ expect(Fauna::Ref.new('classes').class_).to be_nil
38
+ end
39
+ end
40
+
41
+ context 'with native classes' do
42
+ it 'does not return class portion' do
43
+ expect(Fauna::Native.classes.class_).to be_nil
44
+ expect(Fauna::Native.indexes.class_).to be_nil
45
+ expect(Fauna::Native.databases.class_).to be_nil
46
+ expect(Fauna::Native.functions.class_).to be_nil
47
+ expect(Fauna::Native.keys.class_).to be_nil
48
+ end
49
+ end
50
+ end
51
+
52
+ describe '#database' do
53
+ db = Fauna::Ref.new('db', Fauna::Native.databases)
54
+
55
+ context 'with simple database' do
56
+ it 'returns database portion' do
57
+ expect(Fauna::Ref.new('test', Fauna::Native.classes, db).database).to eq(Fauna::Ref.new('db', Fauna::Native.databases))
58
+ end
59
+ end
60
+
61
+ context 'with nested database' do
62
+ it 'returns database portion' do
63
+ nested_db = Fauna::Ref.new('nested-db', Fauna::Native.databases, db)
64
+ deep_db = Fauna::Ref.new('deep-db', Fauna::Native.databases, nested_db)
65
+
66
+ expect(nested_db.database).to eq(db)
67
+ expect(deep_db.database.database).to eq(db)
68
+ end
69
+ end
70
+
71
+ context 'with native classes' do
72
+ it 'does not return database portion' do
73
+ expect(Fauna::Native.classes.database).to be_nil
74
+ expect(Fauna::Native.indexes.database).to be_nil
75
+ expect(Fauna::Native.databases.database).to be_nil
76
+ expect(Fauna::Native.functions.database).to be_nil
77
+ expect(Fauna::Native.keys.database).to be_nil
78
+ end
79
+ end
80
+ end
81
+
82
+ describe '#==' do
83
+ it 'equals same ref' do
84
+ ref = Fauna::Ref.new('123', Fauna::Ref.new('test', Fauna::Native.classes))
85
+
86
+ expect(ref).to eq(Fauna::Ref.new('123', Fauna::Ref.new('test', Fauna::Native.classes)))
87
+ end
88
+
89
+ it 'does not equal different ref' do
90
+ ref = Fauna::Ref.new('123', Fauna::Ref.new('test', Fauna::Native.classes))
91
+
92
+ expect(ref).not_to eq(Fauna::Ref.new('321', Fauna::Ref.new('test', Fauna::Native.classes)))
93
+ end
94
+
95
+ it 'does not equal other type' do
96
+ expect(Fauna::Ref.new('test', Fauna::Native.classes)).not_to eq('classes/test')
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,23 @@
1
+ RSpec.describe Fauna::SetRef do
2
+ describe '#==' do
3
+ it 'equals same set' do
4
+ data = { match: random_ref_string, terms: random_string }
5
+ set = Fauna::SetRef.new(data)
6
+
7
+ expect(set).to eq(Fauna::SetRef.new(data))
8
+ end
9
+
10
+ it 'does not equal different set' do
11
+ set = Fauna::SetRef.new(match: random_ref_string, terms: random_string)
12
+
13
+ expect(set).not_to eq(Fauna::SetRef.new(match: random_ref_string, terms: random_string))
14
+ end
15
+
16
+ it 'does not equal other type' do
17
+ data = { match: random_ref_string, terms: random_string }
18
+ set = Fauna::SetRef.new(data)
19
+
20
+ expect(set).not_to eq(data)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,27 @@
1
+ require 'simplecov'
2
+ require 'fauna'
3
+ require 'fauna_helper'
4
+
5
+ # Reference http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
6
+ RSpec.configure do |config|
7
+ config.expect_with :rspec do |expectations|
8
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
9
+ end
10
+
11
+ config.mock_with :rspec do |mocks|
12
+ mocks.verify_partial_doubles = true
13
+ end
14
+
15
+ # Disable monkey patching
16
+ config.disable_monkey_patching!
17
+
18
+ # Enable warnings
19
+ config.warnings = true
20
+
21
+ # Setup test order
22
+ config.order = :random
23
+ Kernel.srand config.seed
24
+
25
+ # Include test helpers
26
+ config.include FaunaTestHelpers
27
+ end
@@ -0,0 +1,19 @@
1
+ RSpec.describe 'Fauna Util' do
2
+ describe '#time_from_usecs' do
3
+ it 'converts microseconds to time' do
4
+ time = Time.at(1, 234_567)
5
+ usecs = 1_234_567
6
+
7
+ expect(Fauna.time_from_usecs(usecs)).to eq(time)
8
+ end
9
+ end
10
+
11
+ describe '#usecs_from_time' do
12
+ it 'converts time to microseconds' do
13
+ time = Time.at(1, 234_567)
14
+ usecs = 1_234_567
15
+
16
+ expect(Fauna.usecs_from_time(time)).to eq(usecs)
17
+ end
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,181 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yax-fauna
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Forked from Fauna, Inc.
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-09-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: net-http-persistent
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.9'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.3'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov-json
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.2.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.2.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec_junit_formatter
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.3.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.3.0
97
+ description: Ruby driver for FaunaDB.
98
+ email: daniel@danielkehoe.com
99
+ executables: []
100
+ extensions: []
101
+ extra_rdoc_files:
102
+ - CHANGELOG
103
+ - LICENSE
104
+ - README.md
105
+ files:
106
+ - CHANGELOG
107
+ - Gemfile
108
+ - LICENSE
109
+ - README.md
110
+ - Rakefile
111
+ - fauna.gemspec
112
+ - lib/fauna.rb
113
+ - lib/fauna/client.rb
114
+ - lib/fauna/client_logger.rb
115
+ - lib/fauna/context.rb
116
+ - lib/fauna/deprecate.rb
117
+ - lib/fauna/errors.rb
118
+ - lib/fauna/json.rb
119
+ - lib/fauna/objects.rb
120
+ - lib/fauna/page.rb
121
+ - lib/fauna/query.rb
122
+ - lib/fauna/request_result.rb
123
+ - lib/fauna/util.rb
124
+ - lib/fauna/version.rb
125
+ - spec/bytes_spec.rb
126
+ - spec/client_logger_spec.rb
127
+ - spec/client_spec.rb
128
+ - spec/context_spec.rb
129
+ - spec/errors_spec.rb
130
+ - spec/fauna_helper.rb
131
+ - spec/json_spec.rb
132
+ - spec/page_spec.rb
133
+ - spec/query_spec.rb
134
+ - spec/queryv_spec.rb
135
+ - spec/ref_spec.rb
136
+ - spec/setref_spec.rb
137
+ - spec/spec_helper.rb
138
+ - spec/util_spec.rb
139
+ homepage: https://github.com/yaxdotcom/yax-faunadb-ruby
140
+ licenses:
141
+ - MPL-2.0
142
+ metadata: {}
143
+ post_install_message:
144
+ rdoc_options:
145
+ - "--line-numbers"
146
+ - "--title"
147
+ - Fauna
148
+ - "--main"
149
+ - README.md
150
+ require_paths:
151
+ - lib
152
+ required_ruby_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ required_rubygems_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ requirements: []
163
+ rubygems_version: 3.1.2
164
+ signing_key:
165
+ specification_version: 4
166
+ summary: FaunaDB Ruby driver
167
+ test_files:
168
+ - spec/spec_helper.rb
169
+ - spec/client_spec.rb
170
+ - spec/bytes_spec.rb
171
+ - spec/fauna_helper.rb
172
+ - spec/context_spec.rb
173
+ - spec/json_spec.rb
174
+ - spec/page_spec.rb
175
+ - spec/setref_spec.rb
176
+ - spec/util_spec.rb
177
+ - spec/ref_spec.rb
178
+ - spec/client_logger_spec.rb
179
+ - spec/errors_spec.rb
180
+ - spec/query_spec.rb
181
+ - spec/queryv_spec.rb