rsolr 1.1.2 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  require 'spec_helper'
2
- describe "RSolr::Pagination" do
2
+
3
+ RSpec.describe RSolr::Client do
3
4
  context "build_paginated_request" do
4
5
  it "should create the proper solr params and query string" do
5
6
  c = RSolr::Client.new(nil, {})#.extend(RSolr::Pagination::Client)
@@ -11,13 +12,6 @@ describe "RSolr::Pagination" do
11
12
  expect(r[:uri].query).to match(/rows=25/)
12
13
  expect(r[:uri].query).to match(/start=50/)
13
14
  end
14
-
15
- it 'passes through client options' do
16
- c = RSolr::Client.new(nil, open_timeout: 5, read_timeout: 7)
17
- r = c.build_paginated_request 3, 25, "select", {:params => {:q => "test"}}
18
- expect(r[:open_timeout]).to eq(5)
19
- expect(r[:read_timeout]).to eq(7)
20
- end
21
15
  end
22
16
  context "paginate" do
23
17
  it "should build a paginated request context and call execute" do
@@ -28,7 +22,7 @@ describe "RSolr::Pagination" do
28
22
  :params => {
29
23
  "rows" => 10,
30
24
  "start" => 0,
31
- :wt => :ruby
25
+ :wt => :json
32
26
  }
33
27
  }))
34
28
  c.paginate 1, 10, "select"
@@ -1,5 +1,6 @@
1
1
  require 'spec_helper'
2
- describe "RSolr" do
2
+
3
+ RSpec.describe RSolr do
3
4
 
4
5
  it "has a version that can be read via #version or VERSION" do
5
6
  expect(RSolr.version).to eq(RSolr::VERSION)
@@ -27,13 +28,4 @@ describe "RSolr" do
27
28
  expect(RSolr.solr_escape(str)).to eq str
28
29
  end
29
30
  end
30
-
31
- # deprecated as of 2015-02
32
- =begin
33
- it "can escape" do
34
- expect(RSolr).to be_a(RSolr::Char)
35
- expect(RSolr.escape("this string")).to eq("this\\ string")
36
- end
37
- =end
38
-
39
- end
31
+ end
data/spec/api/uri_spec.rb CHANGED
@@ -1,48 +1,8 @@
1
1
  require 'spec_helper'
2
- describe "RSolr::Uri" do
2
+
3
+ RSpec.describe RSolr::Uri do
3
4
 
4
5
  let(:uri) { RSolr::Uri }
5
-
6
- context '.create' do
7
- it "returns a URI object" do
8
- u = uri.create 'http://apache.org'
9
- expect(u).to be_a_kind_of URI
10
- end
11
- it "calls URI.parse" do
12
- expect(URI).to receive(:parse).twice.and_call_original
13
- u = uri.create 'http://apache.org'
14
- end
15
- it "adds a trailing slash after host if there is none" do
16
- u = uri.create 'http://apache.org'
17
- u_str = u.to_s
18
- size = u_str.size
19
- expect(u_str[size - 1]).to eq '/'
20
- end
21
- it "does not add trailing slash after host if there already is one" do
22
- u = uri.create 'http://apache.org/'
23
- u_str = u.to_s
24
- size = u_str.size
25
- expect(u_str[size - 2, 2]).to eq 'g/'
26
- end
27
- it "adds a trailing slash after path if there is none" do
28
- u = uri.create 'http://apache.org/lucene'
29
- u_str = u.to_s
30
- size = u_str.size
31
- expect(u_str[size - 1]).to eq '/'
32
- end
33
- it "does not add trailing slash after path if there already is one" do
34
- u = uri.create 'http://apache.org/lucene/'
35
- u_str = u.to_s
36
- size = u_str.size
37
- expect(u_str[size - 2, 2]).to eq 'e/'
38
- end
39
- it "does not add trailing slash if there are query params" do
40
- u = uri.create 'http://apache.org?foo=bar'
41
- u_str = u.to_s
42
- size = u_str.size
43
- expect(u_str[size - 1]).not_to eq '/'
44
- end
45
- end
46
6
 
47
7
  context '.params_to_solr' do
48
8
  it "converts Hash to Solr query string w/o a starting ?" do
@@ -74,55 +34,4 @@ describe "RSolr::Uri" do
74
34
  expect(uri.params_to_solr(my_params)).to eq(expected)
75
35
  end
76
36
  end
77
-
78
- =begin
79
- # deprecated
80
- context '.build_param' do
81
- it "calls URI.encode_www_form_component by default" do
82
- expect(URI).to receive(:encode_www_form_component).twice
83
- uri.build_param("foo", "bar")
84
- end
85
- it "calls URI.encode_www_form_component if escape arg = true" do
86
- expect(URI).to receive(:encode_www_form_component).twice
87
- uri.build_param("foo", "bar", true)
88
- end
89
- it "doesn't call URI.encode_www_form_component if escape arg = false" do
90
- expect(URI).not_to receive(:encode_www_form_component)
91
- uri.build_param("foo", "bar", false)
92
- end
93
- end
94
-
95
- # deprecated
96
- context ".escape_query_value" do
97
- it 'should escape properly' do
98
- expect(uri.escape_query_value('+')).to eq('%2B')
99
- expect(uri.escape_query_value('This is a test')).to eq('This+is+a+test')
100
- expect(uri.escape_query_value('<>/\\')).to eq('%3C%3E%2F%5C')
101
- expect(uri.escape_query_value('"')).to eq('%22')
102
- expect(uri.escape_query_value(':')).to eq('%3A')
103
- end
104
-
105
- it 'should escape brackets' do
106
- expect(uri.escape_query_value('{')).to eq('%7B')
107
- expect(uri.escape_query_value('}')).to eq('%7D')
108
- end
109
-
110
- it 'should escape exclamation marks!' do
111
- expect(uri.escape_query_value('!')).to eq('%21')
112
- end
113
- end
114
-
115
- # deprecated
116
- context '.bytesize' do
117
- it "calls .bytesize for String" do
118
- str = "testing"
119
- expect(str).to receive(:bytesize)
120
- uri.bytesize(str)
121
- end
122
- it "returns the size of a String" do
123
- expect(uri.bytesize("test")).to eq(4)
124
- end
125
- end
126
- =end
127
-
128
37
  end
data/spec/api/xml_spec.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
  require 'builder'
3
3
  require 'nokogiri'
4
- describe "RSolr::Xml" do
5
-
4
+
5
+ RSpec.describe RSolr::Xml do
6
6
  let(:generator){ RSolr::Xml::Generator.new }
7
7
 
8
8
  builder_engines = {
@@ -52,8 +52,6 @@ describe "RSolr::Xml" do
52
52
  add_attrs = {:boost=>200.00}
53
53
  result = generator.add(documents, add_attrs) do |doc|
54
54
  doc.field_by_name(:name).attrs[:boost] = 10
55
- expect(doc.fields.size).to eq(4)
56
- expect(doc.fields_by_name(:cat).size).to eq(2)
57
55
  end
58
56
  expect(result).to match(%r(name="cat">cat 1</field>))
59
57
  expect(result).to match(%r(name="cat">cat 2</field>))
@@ -81,6 +79,26 @@ describe "RSolr::Xml" do
81
79
  expect(result).to match(/<field name="id">1<\/field>/)
82
80
  end
83
81
 
82
+ # add a single hash ("doc")
83
+ it 'should create an add from a hash formatted for atomic updates' do
84
+ data = {
85
+ :id=>1,
86
+ :name=> { set: 'matt' }
87
+ }
88
+ result = generator.add(data)
89
+ expect(result).to match(/<field name="name" update="set">matt<\/field>/)
90
+ expect(result).to match(/<field name="id">1<\/field>/)
91
+ end
92
+ it 'should remove a field from a hash formatted for atomic updates' do
93
+ data = {
94
+ :id => 1,
95
+ :name => nil
96
+ }
97
+ result = generator.add(data)
98
+ expect(result).to match(%r{<field name="name" null="true"})
99
+ expect(result).to match(/<field name="id">1<\/field>/)
100
+ end
101
+
84
102
  # add an array of hashes
85
103
  it 'should create many adds from an array of hashes' do
86
104
  data = [
@@ -94,9 +112,8 @@ describe "RSolr::Xml" do
94
112
  }
95
113
  ]
96
114
  message = generator.add(data)
97
- expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><add><doc><field name=\"id\">1</field><field name=\"name\">matt</field></doc><doc><field name=\"id\">2</field><field name=\"name\">sam</field></doc></add>"
98
- expect(message).to match(/<field name="name">matt<\/field>/)
99
- expect(message).to match(/<field name="name">sam<\/field>/)
115
+ expect(message).to match %r{<field name="name">matt</field>}
116
+ expect(message).to match %r{<field name="name">sam</field>}
100
117
  end
101
118
 
102
119
  # multiValue field support test, thanks to Fouad Mardini!
@@ -122,7 +139,7 @@ describe "RSolr::Xml" do
122
139
  end
123
140
 
124
141
  it 'should create an add from a single Message::Document' do
125
- document = RSolr::Xml::Document.new
142
+ document = RSolr::Document.new
126
143
  document.add_field('id', 1)
127
144
  document.add_field('name', 'matt', :boost => 2.0)
128
145
  result = generator.add(document)
@@ -135,7 +152,7 @@ describe "RSolr::Xml" do
135
152
 
136
153
  it 'should create adds from multiple Message::Documents' do
137
154
  documents = (1..2).map do |i|
138
- doc = RSolr::Xml::Document.new
155
+ doc = RSolr::Document.new
139
156
  doc.add_field('id', i)
140
157
  doc.add_field('name', "matt#{i}")
141
158
  doc
@@ -144,7 +161,24 @@ describe "RSolr::Xml" do
144
161
  expect(result).to match(/<field name="name">matt1<\/field>/)
145
162
  expect(result).to match(/<field name="name">matt2<\/field>/)
146
163
  end
147
-
164
+
165
+ it 'supports nested child documents' do
166
+ data = {
167
+ :_childDocuments_ => [
168
+ {
169
+ :id => 1
170
+ },
171
+ {
172
+ :id => 2
173
+ }
174
+ ]
175
+ }
176
+
177
+ result = generator.add(data)
178
+ expect(result).to match(%r{<add><doc><doc>})
179
+ expect(result).to match(%r{<doc><field name="id">1</field></doc>})
180
+ expect(result).to match(%r{<doc><field name="id">2</field></doc>})
181
+ end
148
182
  end
149
183
 
150
184
  context :delete_by_id do
@@ -217,5 +251,5 @@ describe "RSolr::Xml" do
217
251
  expect(result).to match(/<field name="whatever">some string<\/field>/)
218
252
  end
219
253
  end
220
- end
254
+ end
221
255
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'solr_wrapper'
3
3
 
4
- describe "Solr basic_configs" do
4
+ RSpec.describe "Solr basic_configs" do
5
5
  SOLR_INSTANCE = SolrWrapper.default_instance({})
6
6
  before(:all) { SOLR_INSTANCE.start }
7
7
  after(:all) { SOLR_INSTANCE.stop }
@@ -23,4 +23,12 @@ describe "Solr basic_configs" do
23
23
  end
24
24
  end
25
25
  end
26
+
27
+ context "error handling" do
28
+ subject { RSolr.connect url: "http://localhost:65432/solr/basic_configs/"}
29
+
30
+ it "wraps connection errors" do
31
+ expect { subject.head('admin/ping') }.to raise_error RSolr::Error::ConnectionRefused
32
+ end
33
+ end
26
34
  end
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,94 @@
1
+ require 'simplecov'
2
+ SimpleCov.start do
3
+ add_filter "/spec/"
4
+ end
5
+
1
6
  require 'rsolr'
2
7
  require 'rspec'
3
8
 
4
9
  FIXTURES_DIR = File.expand_path("fixtures", File.dirname(__FILE__))
5
10
 
6
- RSpec.configure do |c|
11
+ RSpec.configure do |config|
12
+ # rspec-expectations config goes here. You can use an alternate
13
+ # assertion/expectation library such as wrong or the stdlib/minitest
14
+ # assertions if you prefer.
15
+ config.expect_with :rspec do |expectations|
16
+ # This option will default to `true` in RSpec 4. It makes the `description`
17
+ # and `failure_message` of custom matchers include text for helper methods
18
+ # defined using `chain`, e.g.:
19
+ # be_bigger_than(2).and_smaller_than(4).description
20
+ # # => "be bigger than 2 and smaller than 4"
21
+ # ...rather than:
22
+ # # => "be bigger than 2"
23
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
24
+ end
25
+
26
+ # rspec-mocks config goes here. You can use an alternate test double
27
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
28
+ config.mock_with :rspec do |mocks|
29
+ # Prevents you from mocking or stubbing a method that does not exist on
30
+ # a real object. This is generally recommended, and will default to
31
+ # `true` in RSpec 4.
32
+ mocks.verify_partial_doubles = true
33
+ end
34
+
35
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
36
+ # have no way to turn it off -- the option exists only for backwards
37
+ # compatibility in RSpec 3). It causes shared context metadata to be
38
+ # inherited by the metadata hash of host groups and examples, rather than
39
+ # triggering implicit auto-inclusion in groups with matching metadata.
40
+ config.shared_context_metadata_behavior = :apply_to_host_groups
41
+
42
+ # The settings below are suggested to provide a good initial experience
43
+ # with RSpec, but feel free to customize to your heart's content.
44
+
45
+ # This allows you to limit a spec run to individual examples or groups
46
+ # you care about by tagging them with `:focus` metadata. When nothing
47
+ # is tagged with `:focus`, all examples get run. RSpec also provides
48
+ # aliases for `it`, `describe`, and `context` that include `:focus`
49
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
50
+ config.filter_run_when_matching :focus
51
+
52
+ # Allows RSpec to persist some state between runs in order to support
53
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
54
+ # you configure your source control system to ignore this file.
55
+ config.example_status_persistence_file_path = 'spec/examples.txt'
56
+
57
+ # Limits the available syntax to the non-monkey patched syntax that is
58
+ # recommended. For more details, see:
59
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
60
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
61
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
62
+ config.disable_monkey_patching!
63
+
64
+ # This setting enables warnings. It's recommended, but in some cases may
65
+ # be too noisy due to issues in dependencies.
66
+ config.warnings = true
67
+
68
+ # Many RSpec users commonly either run the entire suite or an individual
69
+ # file, and it's useful to allow more verbose output when running an
70
+ # individual spec file.
71
+ if config.files_to_run.one?
72
+ # Use the documentation formatter for detailed output,
73
+ # unless a formatter has already been configured
74
+ # (e.g. via a command-line flag).
75
+ config.default_formatter = 'doc'
76
+ end
77
+
78
+ # Print the 10 slowest examples and example groups at the
79
+ # end of the spec run, to help surface which specs are running
80
+ # particularly slow.
81
+ config.profile_examples = 10
82
+
83
+ # Run specs in random order to surface order dependencies. If you find an
84
+ # order dependency and want to debug it, you can fix the order by providing
85
+ # the seed, which is printed after each run.
86
+ # --seed 1234
87
+ config.order = :random
7
88
 
8
- end
89
+ # Seed global randomization in this process using the `--seed` CLI option.
90
+ # Setting this allows you to use `--seed` to deterministically reproduce
91
+ # test failures related to randomization by passing the same `--seed` value
92
+ # as the one that triggered the failure.
93
+ Kernel.srand config.seed
94
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsolr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antoine Latter
@@ -29,7 +29,7 @@ authors:
29
29
  autorequire:
30
30
  bindir: bin
31
31
  cert_chain: []
32
- date: 2016-08-19 00:00:00.000000000 Z
32
+ date: 2020-01-13 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: builder
@@ -45,6 +45,20 @@ dependencies:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: 2.1.2
48
+ - !ruby/object:Gem::Dependency
49
+ name: faraday
50
+ requirement: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.9.0
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.0
48
62
  - !ruby/object:Gem::Dependency
49
63
  name: activesupport
50
64
  requirement: !ruby/object:Gem::Requirement
@@ -77,28 +91,28 @@ dependencies:
77
91
  name: rake
78
92
  requirement: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - "~>"
94
+ - - ">="
81
95
  - !ruby/object:Gem::Version
82
96
  version: '10.0'
83
97
  type: :development
84
98
  prerelease: false
85
99
  version_requirements: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - "~>"
101
+ - - ">="
88
102
  - !ruby/object:Gem::Version
89
103
  version: '10.0'
90
104
  - !ruby/object:Gem::Dependency
91
105
  name: rdoc
92
106
  requirement: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - "~>"
108
+ - - ">="
95
109
  - !ruby/object:Gem::Version
96
110
  version: '4.0'
97
111
  type: :development
98
112
  prerelease: false
99
113
  version_requirements: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - "~>"
115
+ - - ">="
102
116
  - !ruby/object:Gem::Version
103
117
  version: '4.0'
104
118
  - !ruby/object:Gem::Dependency
@@ -115,6 +129,20 @@ dependencies:
115
129
  - - "~>"
116
130
  - !ruby/object:Gem::Version
117
131
  version: '3.0'
132
+ - !ruby/object:Gem::Dependency
133
+ name: simplecov
134
+ requirement: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ type: :development
140
+ prerelease: false
141
+ version_requirements: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
118
146
  - !ruby/object:Gem::Dependency
119
147
  name: solr_wrapper
120
148
  requirement: !ruby/object:Gem::Requirement
@@ -138,6 +166,7 @@ extensions: []
138
166
  extra_rdoc_files: []
139
167
  files:
140
168
  - ".gitignore"
169
+ - ".rspec"
141
170
  - ".travis.yml"
142
171
  - CHANGES.txt
143
172
  - Gemfile
@@ -147,17 +176,20 @@ files:
147
176
  - lib/rsolr.rb
148
177
  - lib/rsolr/char.rb
149
178
  - lib/rsolr/client.rb
150
- - lib/rsolr/connection.rb
179
+ - lib/rsolr/document.rb
151
180
  - lib/rsolr/error.rb
181
+ - lib/rsolr/field.rb
182
+ - lib/rsolr/generator.rb
183
+ - lib/rsolr/json.rb
152
184
  - lib/rsolr/response.rb
153
185
  - lib/rsolr/uri.rb
154
186
  - lib/rsolr/version.rb
155
187
  - lib/rsolr/xml.rb
156
188
  - rsolr.gemspec
157
- - spec/api/char_spec.rb
158
189
  - spec/api/client_spec.rb
159
- - spec/api/connection_spec.rb
190
+ - spec/api/document_spec.rb
160
191
  - spec/api/error_spec.rb
192
+ - spec/api/json_spec.rb
161
193
  - spec/api/pagination_spec.rb
162
194
  - spec/api/rsolr_spec.rb
163
195
  - spec/api/uri_spec.rb
@@ -172,9 +204,6 @@ files:
172
204
  - spec/fixtures/basic_configs/synonyms.txt
173
205
  - spec/integration/solr5_spec.rb
174
206
  - spec/spec_helper.rb
175
- - tasks/rdoc.rake
176
- - tasks/rsolr.rake
177
- - tasks/spec.rake
178
207
  homepage: https://github.com/rsolr/rsolr
179
208
  licenses:
180
209
  - Apache-2.0
@@ -193,9 +222,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
222
  - - ">="
194
223
  - !ruby/object:Gem::Version
195
224
  version: '0'
196
- requirements: []
197
- rubyforge_project: rsolr
198
- rubygems_version: 2.5.1
225
+ requirements:
226
+ - Apache Solr
227
+ rubygems_version: 3.0.3
199
228
  signing_key:
200
229
  specification_version: 4
201
230
  summary: A Ruby client for Apache Solr