sunspot 2.2.7 → 2.2.8

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.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rspec +2 -0
  4. data/Appraisals +7 -0
  5. data/Gemfile +0 -8
  6. data/gemfiles/.gitkeep +0 -0
  7. data/lib/sunspot/dsl/scope.rb +6 -1
  8. data/lib/sunspot/field.rb +11 -0
  9. data/lib/sunspot/field_factory.rb +6 -2
  10. data/lib/sunspot/query/bbox.rb +5 -1
  11. data/lib/sunspot/query/restriction.rb +11 -0
  12. data/lib/sunspot/search/hit_enumerable.rb +4 -1
  13. data/lib/sunspot/search/standard_search.rb +2 -3
  14. data/lib/sunspot/version.rb +1 -1
  15. data/spec/api/adapters_spec.rb +19 -19
  16. data/spec/api/batcher_spec.rb +15 -15
  17. data/spec/api/binding_spec.rb +3 -3
  18. data/spec/api/class_set_spec.rb +3 -3
  19. data/spec/api/hit_enumerable_spec.rb +32 -9
  20. data/spec/api/indexer/attributes_spec.rb +31 -31
  21. data/spec/api/indexer/batch_spec.rb +8 -7
  22. data/spec/api/indexer/dynamic_fields_spec.rb +8 -8
  23. data/spec/api/indexer/fixed_fields_spec.rb +12 -12
  24. data/spec/api/indexer/fulltext_spec.rb +8 -8
  25. data/spec/api/indexer/removal_spec.rb +14 -14
  26. data/spec/api/indexer_spec.rb +2 -2
  27. data/spec/api/query/advanced_manipulation_examples.rb +3 -3
  28. data/spec/api/query/connectives_examples.rb +26 -14
  29. data/spec/api/query/dsl_spec.rb +17 -9
  30. data/spec/api/query/dynamic_fields_examples.rb +18 -18
  31. data/spec/api/query/faceting_examples.rb +62 -62
  32. data/spec/api/query/fulltext_examples.rb +56 -55
  33. data/spec/api/query/function_spec.rb +26 -26
  34. data/spec/api/query/geo_examples.rb +6 -6
  35. data/spec/api/query/group_spec.rb +6 -6
  36. data/spec/api/query/highlighting_examples.rb +26 -26
  37. data/spec/api/query/join_spec.rb +2 -2
  38. data/spec/api/query/more_like_this_spec.rb +29 -29
  39. data/spec/api/query/ordering_pagination_examples.rb +25 -25
  40. data/spec/api/query/scope_examples.rb +39 -39
  41. data/spec/api/query/spatial_examples.rb +3 -3
  42. data/spec/api/query/spellcheck_examples.rb +3 -3
  43. data/spec/api/query/standard_spec.rb +1 -1
  44. data/spec/api/query/stats_examples.rb +8 -8
  45. data/spec/api/query/text_field_scoping_examples.rb +5 -5
  46. data/spec/api/query/types_spec.rb +4 -4
  47. data/spec/api/search/cursor_paginated_collection_spec.rb +12 -12
  48. data/spec/api/search/dynamic_fields_spec.rb +4 -4
  49. data/spec/api/search/faceting_spec.rb +55 -52
  50. data/spec/api/search/highlighting_spec.rb +7 -7
  51. data/spec/api/search/hits_spec.rb +29 -29
  52. data/spec/api/search/paginated_collection_spec.rb +18 -18
  53. data/spec/api/search/results_spec.rb +13 -13
  54. data/spec/api/search/search_spec.rb +3 -3
  55. data/spec/api/search/stats_spec.rb +10 -10
  56. data/spec/api/session_proxy/class_sharding_session_proxy_spec.rb +19 -18
  57. data/spec/api/session_proxy/id_sharding_session_proxy_spec.rb +9 -9
  58. data/spec/api/session_proxy/master_slave_session_proxy_spec.rb +10 -6
  59. data/spec/api/session_proxy/retry_5xx_session_proxy_spec.rb +10 -10
  60. data/spec/api/session_proxy/sharding_session_proxy_spec.rb +14 -13
  61. data/spec/api/session_proxy/silent_fail_session_proxy_spec.rb +2 -2
  62. data/spec/api/session_proxy/spec_helper.rb +1 -1
  63. data/spec/api/session_proxy/thread_local_session_proxy_spec.rb +9 -5
  64. data/spec/api/session_spec.rb +42 -42
  65. data/spec/api/sunspot_spec.rb +4 -4
  66. data/spec/integration/atomic_updates_spec.rb +25 -11
  67. data/spec/integration/dynamic_fields_spec.rb +10 -10
  68. data/spec/integration/faceting_spec.rb +39 -39
  69. data/spec/integration/field_grouping_spec.rb +16 -16
  70. data/spec/integration/field_lists_spec.rb +41 -0
  71. data/spec/integration/geospatial_spec.rb +19 -8
  72. data/spec/integration/highlighting_spec.rb +5 -5
  73. data/spec/integration/indexing_spec.rb +5 -5
  74. data/spec/integration/keyword_search_spec.rb +47 -45
  75. data/spec/integration/local_search_spec.rb +4 -4
  76. data/spec/integration/more_like_this_spec.rb +7 -7
  77. data/spec/integration/scoped_search_spec.rb +107 -107
  78. data/spec/integration/spellcheck_spec.rb +52 -7
  79. data/spec/integration/stats_spec.rb +10 -10
  80. data/spec/integration/stored_fields_spec.rb +1 -1
  81. data/spec/integration/test_pagination.rb +4 -4
  82. data/spec/integration/unicode_spec.rb +1 -1
  83. data/spec/mocks/post.rb +5 -1
  84. data/spec/spec_helper.rb +11 -6
  85. data/sunspot.gemspec +3 -1
  86. metadata +40 -7
@@ -9,8 +9,8 @@ describe Sunspot::SessionProxy::ClassShardingSessionProxy do
9
9
  it "should delegate #{method} to appropriate shard" do
10
10
  post = Post.new
11
11
  photo = Photo.new
12
- @proxy.post_session.should_receive(method).with([post])
13
- @proxy.photo_session.should_receive(method).with([photo])
12
+ expect(@proxy.post_session).to receive(method).with([post])
13
+ expect(@proxy.photo_session).to receive(method).with([photo])
14
14
  @proxy.send(method, post)
15
15
  @proxy.send(method, photo)
16
16
  end
@@ -18,14 +18,14 @@ describe Sunspot::SessionProxy::ClassShardingSessionProxy do
18
18
 
19
19
  [:remove_by_id, :remove_by_id!].each do |method|
20
20
  it "should delegate #{method} to appropriate shard" do
21
- @proxy.post_session.should_receive(method).with(Post, [1])
22
- @proxy.photo_session.should_receive(method).with(Photo, [1])
21
+ expect(@proxy.post_session).to receive(method).with(Post, [1])
22
+ expect(@proxy.photo_session).to receive(method).with(Photo, [1])
23
23
  @proxy.send(method, Post, 1)
24
24
  @proxy.send(method, Photo, 1)
25
25
  end
26
26
  it "should delegate #{method} to appropriate shard given ids" do
27
- @proxy.post_session.should_receive(method).with(Post, [1, 2])
28
- @proxy.photo_session.should_receive(method).with(Photo, [1, 2])
27
+ expect(@proxy.post_session).to receive(method).with(Post, [1, 2])
28
+ expect(@proxy.photo_session).to receive(method).with(Photo, [1, 2])
29
29
  @proxy.send(method, Post, 1, 2)
30
30
  @proxy.send(method, Photo, [1, 2])
31
31
  end
@@ -33,15 +33,15 @@ describe Sunspot::SessionProxy::ClassShardingSessionProxy do
33
33
 
34
34
  [:remove_all, :remove_all!].each do |method|
35
35
  it "should delegate #{method} with argument to appropriate shard" do
36
- @proxy.post_session.should_receive(method).with(Post)
37
- @proxy.photo_session.should_receive(method).with(Photo)
36
+ expect(@proxy.post_session).to receive(method).with(Post)
37
+ expect(@proxy.photo_session).to receive(method).with(Photo)
38
38
  @proxy.send(method, Post)
39
39
  @proxy.send(method, Photo)
40
40
  end
41
41
 
42
42
  it "should delegate #{method} without argument to all shards" do
43
- @proxy.post_session.should_receive(method)
44
- @proxy.photo_session.should_receive(method)
43
+ expect(@proxy.post_session).to receive(method)
44
+ expect(@proxy.photo_session).to receive(method)
45
45
  @proxy.send(method)
46
46
  end
47
47
  end
@@ -49,42 +49,43 @@ describe Sunspot::SessionProxy::ClassShardingSessionProxy do
49
49
  [:commit, :commit_if_dirty, :commit_if_delete_dirty, :optimize].each do |method|
50
50
  it "should delegate #{method} to all sessions" do
51
51
  [@proxy.post_session, @proxy.photo_session].each do |session|
52
- session.should_receive(method)
52
+ expect(session).to receive(method)
53
53
  end
54
54
  @proxy.send(method)
55
55
  end
56
56
  end
57
57
 
58
58
  it "should not support the :batch method" do
59
- lambda { @proxy.batch }.should raise_error(Sunspot::SessionProxy::NotSupportedError)
59
+ expect { @proxy.batch }.to raise_error(Sunspot::SessionProxy::NotSupportedError)
60
60
  end
61
61
 
62
62
  it "should delegate new_search to search session, adding in shards parameter" do
63
63
  search = @proxy.new_search(Post)
64
- search.query[:shards].should ==
64
+ expect(search.query[:shards]).to eq(
65
65
  'http://photos.solr.local/solr,http://posts.solr.local/solr'
66
+ )
66
67
  end
67
68
 
68
69
  it "should delegate search to search session, adding in shards parameter" do
69
70
  @proxy.search(Post)
70
- connection.should have_last_search_with(
71
+ expect(connection).to have_last_search_with(
71
72
  :shards => 'http://photos.solr.local/solr,http://posts.solr.local/solr'
72
73
  )
73
74
  end
74
75
 
75
76
  [:dirty, :delete_dirty].each do |method|
76
77
  it "should be dirty if any of the sessions are dirty" do
77
- @proxy.post_session.stub(:"#{method}?").and_return(true)
78
- @proxy.should send("be_#{method}")
78
+ allow(@proxy.post_session).to receive(:"#{method}?").and_return(true)
79
+ expect(@proxy).to send("be_#{method}")
79
80
  end
80
81
 
81
82
  it "should not be dirty if none of the sessions are dirty" do
82
- @proxy.should_not send("be_#{method}")
83
+ expect(@proxy).not_to send("be_#{method}")
83
84
  end
84
85
  end
85
86
 
86
87
  it "should raise a NotSupportedError when :config is called" do
87
- lambda { @proxy.config }.should raise_error(Sunspot::SessionProxy::NotSupportedError)
88
+ expect { @proxy.config }.to raise_error(Sunspot::SessionProxy::NotSupportedError)
88
89
  end
89
90
 
90
91
  it_should_behave_like 'session proxy'
@@ -10,8 +10,8 @@ describe Sunspot::SessionProxy::ShardingSessionProxy do
10
10
  [:index, :index!, :remove, :remove!].each do |method|
11
11
  it "should delegate #{method} to appropriate shard" do
12
12
  posts = [Post.new(:id => 2), Post.new(:id => 1)]
13
- @proxy.sessions[0].should_receive(method).with([posts[0]])
14
- @proxy.sessions[1].should_receive(method).with([posts[1]])
13
+ expect(@proxy.sessions[0]).to receive(method).with([posts[0]])
14
+ expect(@proxy.sessions[1]).to receive(method).with([posts[1]])
15
15
  @proxy.send(method, posts[0])
16
16
  @proxy.send(method, posts[1])
17
17
  end
@@ -19,21 +19,21 @@ describe Sunspot::SessionProxy::ShardingSessionProxy do
19
19
 
20
20
  [:remove_by_id, :remove_by_id!].each do |method|
21
21
  it "should delegate #{method} to appropriate session" do
22
- @proxy.sessions[1].should_receive(method).with(Post, [3])
23
- @proxy.sessions[0].should_receive(method).with(Post, [2])
24
- @proxy.sessions[1].should_receive(method).with(Post, [1])
22
+ expect(@proxy.sessions[1]).to receive(method).with(Post, [3])
23
+ expect(@proxy.sessions[0]).to receive(method).with(Post, [2])
24
+ expect(@proxy.sessions[1]).to receive(method).with(Post, [1])
25
25
  @proxy.send(method, Post, 1)
26
26
  @proxy.send(method, Post, 2)
27
27
  @proxy.send(method, Post, 3)
28
28
  end
29
29
  it "should delegate #{method} to appropriate session given splatted index ids" do
30
- @proxy.sessions[0].should_receive(method).with(Post, [2])
31
- @proxy.sessions[1].should_receive(method).with(Post, [1, 3])
30
+ expect(@proxy.sessions[0]).to receive(method).with(Post, [2])
31
+ expect(@proxy.sessions[1]).to receive(method).with(Post, [1, 3])
32
32
  @proxy.send(method, Post, 1, 2, 3)
33
33
  end
34
34
  it "should delegate #{method} to appropriate session given array of index ids" do
35
- @proxy.sessions[0].should_receive(method).with(Post, [2])
36
- @proxy.sessions[1].should_receive(method).with(Post, [1, 3])
35
+ expect(@proxy.sessions[0]).to receive(method).with(Post, [2])
36
+ expect(@proxy.sessions[1]).to receive(method).with(Post, [1, 3])
37
37
  @proxy.send(method, Post, [1, 2, 3])
38
38
  end
39
39
  end
@@ -13,28 +13,32 @@ describe Sunspot::SessionProxy::MasterSlaveSessionProxy do
13
13
  methods.each do |method|
14
14
  it "should delegate #{method} to #{delegate}" do
15
15
  args = Array.new(Sunspot::Session.instance_method(method).arity.abs) do
16
- stub('arg')
16
+ double('arg')
17
+ end
18
+ if args.empty?
19
+ expect(instance_variable_get(:"@#{delegate}")).to receive(method).with(no_args)
20
+ else
21
+ expect(instance_variable_get(:"@#{delegate}")).to receive(method).with(*args)
17
22
  end
18
- instance_variable_get(:"@#{delegate}").should_receive(method).with(*args)
19
23
  @proxy.send(method, *args)
20
24
  end
21
25
  end
22
26
  end
23
27
 
24
28
  it 'should return master session config by default' do
25
- @proxy.config.should eql(@master_session.config)
29
+ expect(@proxy.config).to eql(@master_session.config)
26
30
  end
27
31
 
28
32
  it 'should return master session config when specified' do
29
- @proxy.config(:master).should eql(@master_session.config)
33
+ expect(@proxy.config(:master)).to eql(@master_session.config)
30
34
  end
31
35
 
32
36
  it 'should return slave session config when specified' do
33
- @proxy.config(:slave).should eql(@slave_session.config)
37
+ expect(@proxy.config(:slave)).to eql(@slave_session.config)
34
38
  end
35
39
 
36
40
  it 'should raise ArgumentError when bogus config specified' do
37
- lambda { @proxy.config(:bogus) }.should raise_error
41
+ expect { @proxy.config(:bogus) }.to raise_error
38
42
  end
39
43
 
40
44
  it_should_behave_like 'session proxy'
@@ -33,14 +33,14 @@ describe Sunspot::SessionProxy::Retry5xxSessionProxy do
33
33
  end
34
34
 
35
35
  it "should behave normally without a stubbed exception" do
36
- @sunspot_session.should_receive(:index).and_return(double)
36
+ expect(@sunspot_session).to receive(:index).and_return(double)
37
37
  Sunspot.index(post)
38
38
  end
39
39
 
40
40
  it "should be successful with a single exception followed by a sucess" do
41
41
  e = FakeRSolrErrorHttp.new(fake_rsolr_request, fake_rsolr_response(503))
42
- @sunspot_session.should_receive(:index).and_return do
43
- @sunspot_session.should_receive(:index).and_return(double)
42
+ expect(@sunspot_session).to receive(:index) do
43
+ expect(@sunspot_session).to receive(:index).and_return(double)
44
44
  raise e
45
45
  end
46
46
  Sunspot.index(post)
@@ -51,23 +51,23 @@ describe Sunspot::SessionProxy::Retry5xxSessionProxy do
51
51
  e = FakeRSolrErrorHttp.new(fake_rsolr_request, fake_response)
52
52
  fake_success = double('success')
53
53
 
54
- @sunspot_session.should_receive(:index).and_return do
55
- @sunspot_session.should_receive(:index).and_return do
56
- @sunspot_session.stub(:index).and_return(fake_success)
54
+ expect(@sunspot_session).to receive(:index) do
55
+ expect(@sunspot_session).to receive(:index) do
56
+ allow(@sunspot_session).to receive(:index).and_return(fake_success)
57
57
  raise e
58
58
  end
59
59
  raise e
60
60
  end
61
61
 
62
62
  response = Sunspot.index(post)
63
- response.should_not == fake_success
64
- response.should == fake_response
63
+ expect(response).not_to eq(fake_success)
64
+ expect(response).to eq(fake_response)
65
65
  end
66
66
 
67
67
  it "should not retry a 4xx" do
68
68
  e = FakeRSolrErrorHttp.new(fake_rsolr_request, fake_rsolr_response(400))
69
- @sunspot_session.should_receive(:index).and_raise(e)
70
- lambda { Sunspot.index(post) }.should raise_error
69
+ expect(@sunspot_session).to receive(:index).and_raise(e)
70
+ expect { Sunspot.index(post) }.to raise_error
71
71
  end
72
72
 
73
73
  # TODO: try against more than just Sunspot.index? but that's just testing the
@@ -8,8 +8,8 @@ describe Sunspot::SessionProxy::ShardingSessionProxy do
8
8
  [:index, :index!, :remove, :remove!].each do |method|
9
9
  it "should delegate #{method} to appropriate shard" do
10
10
  posts = [Post.new(:blog_id => 2), Post.new(:blog_id => 3)]
11
- @proxy.sessions[0].should_receive(method).with([posts[0]])
12
- @proxy.sessions[1].should_receive(method).with([posts[1]])
11
+ expect(@proxy.sessions[0]).to receive(method).with([posts[0]])
12
+ expect(@proxy.sessions[1]).to receive(method).with([posts[1]])
13
13
  @proxy.send(method, posts[0])
14
14
  @proxy.send(method, posts[1])
15
15
  end
@@ -17,17 +17,17 @@ describe Sunspot::SessionProxy::ShardingSessionProxy do
17
17
 
18
18
  [:remove_by_id, :remove_by_id!, :atomic_update, :atomic_update!].each do |method|
19
19
  it "should raise NotSupportedError when #{method} called" do
20
- lambda { @proxy.send(method, Post, 1) }.should raise_error(Sunspot::SessionProxy::NotSupportedError)
20
+ expect { @proxy.send(method, Post, 1) }.to raise_error(Sunspot::SessionProxy::NotSupportedError)
21
21
  end
22
22
  end
23
23
 
24
24
  [:remove_all, :remove_all!].each do |method|
25
25
  it "should raise NotSupportedError when #{method} called with argument" do
26
- lambda { @proxy.send(method, Post) }.should raise_error(Sunspot::SessionProxy::NotSupportedError)
26
+ expect { @proxy.send(method, Post) }.to raise_error(Sunspot::SessionProxy::NotSupportedError)
27
27
  end
28
28
 
29
29
  it "should delegate #{method} without argument to all shards" do
30
- @proxy.sessions.each { |session| session.should_receive(method) }
30
+ @proxy.sessions.each { |session| expect(session).to receive(method) }
31
31
  @proxy.send(method)
32
32
  end
33
33
  end
@@ -35,42 +35,43 @@ describe Sunspot::SessionProxy::ShardingSessionProxy do
35
35
  [:commit, :commit_if_dirty, :commit_if_delete_dirty, :optimize].each do |method|
36
36
  it "should delegate #{method} to all sessions" do
37
37
  @proxy.sessions.each do |session|
38
- session.should_receive(method)
38
+ expect(session).to receive(method)
39
39
  end
40
40
  @proxy.send(method)
41
41
  end
42
42
  end
43
43
 
44
44
  it "should not support the :batch method" do
45
- lambda { @proxy.batch }.should raise_error(Sunspot::SessionProxy::NotSupportedError)
45
+ expect { @proxy.batch }.to raise_error(Sunspot::SessionProxy::NotSupportedError)
46
46
  end
47
47
 
48
48
  it "should delegate new_search to search session, adding in shards parameter" do
49
49
  search = @proxy.new_search(Post)
50
- search.query[:shards].should ==
50
+ expect(search.query[:shards]).to eq(
51
51
  'http://localhost:8980/solr,http://localhost:8981/solr'
52
+ )
52
53
  end
53
54
 
54
55
  it "should delegate search to search session, adding in shards parameter" do
55
56
  @proxy.search(Post)
56
- connection.should have_last_search_with(
57
+ expect(connection).to have_last_search_with(
57
58
  :shards => 'http://localhost:8980/solr,http://localhost:8981/solr'
58
59
  )
59
60
  end
60
61
 
61
62
  [:dirty, :delete_dirty].each do |method|
62
63
  it "should be dirty if any of the sessions are dirty" do
63
- @proxy.sessions[0].stub(:"#{method}?").and_return(true)
64
- @proxy.should send("be_#{method}")
64
+ allow(@proxy.sessions[0]).to receive(:"#{method}?").and_return(true)
65
+ expect(@proxy).to send("be_#{method}")
65
66
  end
66
67
 
67
68
  it "should not be dirty if none of the sessions are dirty" do
68
- @proxy.should_not send("be_#{method}")
69
+ expect(@proxy).not_to send("be_#{method}")
69
70
  end
70
71
  end
71
72
 
72
73
  it "should raise a NotSupportedError when :config is called" do
73
- lambda { @proxy.config }.should raise_error(Sunspot::SessionProxy::NotSupportedError)
74
+ expect { @proxy.config }.to raise_error(Sunspot::SessionProxy::NotSupportedError)
74
75
  end
75
76
 
76
77
  it_should_behave_like 'session proxy'
@@ -13,8 +13,8 @@ describe Sunspot::SessionProxy::ShardingSessionProxy do
13
13
  it "should call rescued_exception when an exception is caught" do
14
14
  SUPPORTED_METHODS.each do |method|
15
15
  e = FakeException.new(method)
16
- @search_session.stub(method).and_raise(e)
17
- @proxy.should_receive(:rescued_exception).with(method, e)
16
+ allow(@search_session).to receive(method).and_raise(e)
17
+ expect(@proxy).to receive(:rescued_exception).with(method, e)
18
18
  @proxy.send(method)
19
19
  end
20
20
  end
@@ -3,7 +3,7 @@ require File.expand_path('spec_helper', File.join(File.dirname(__FILE__), '..'))
3
3
  shared_examples_for 'session proxy' do
4
4
  Sunspot::Session.public_instance_methods(false).each do |method|
5
5
  it "should respond to #{method.inspect}" do
6
- @proxy.should respond_to(method)
6
+ expect(@proxy).to respond_to(method)
7
7
  end
8
8
  end
9
9
  end
@@ -17,7 +17,7 @@ describe Sunspot::SessionProxy::ThreadLocalSessionProxy do
17
17
  end
18
18
 
19
19
  it 'should have the same session for the same thread' do
20
- @proxy.session.should eql(@proxy.session)
20
+ expect(@proxy.session).to eql(@proxy.session)
21
21
  end
22
22
 
23
23
  it 'should not have the same session for different threads' do
@@ -26,20 +26,24 @@ describe Sunspot::SessionProxy::ThreadLocalSessionProxy do
26
26
  Thread.new do
27
27
  session2 = @proxy.session
28
28
  end.join
29
- session1.should_not eql(session2)
29
+ expect(session1).not_to eql(session2)
30
30
  end
31
31
 
32
32
  it 'should not have the same session for the same thread in different proxy instances' do
33
33
  proxy2 = Sunspot::SessionProxy::ThreadLocalSessionProxy.new(@config)
34
- @proxy.session.should_not eql(proxy2.session)
34
+ expect(@proxy.session).not_to eql(proxy2.session)
35
35
  end
36
36
 
37
37
  (Sunspot::Session.public_instance_methods(false) - ['config', :config]).each do |method|
38
38
  it "should delegate #{method.inspect} to its session" do
39
39
  args = Array.new(Sunspot::Session.instance_method(method).arity.abs) do
40
- stub('arg')
40
+ double('arg')
41
+ end
42
+ if args.empty?
43
+ expect(@proxy.session).to receive(method).with(no_args)
44
+ else
45
+ expect(@proxy.session).to receive(method).with(*args)
41
46
  end
42
- @proxy.session.should_receive(method).with(*args)
43
47
  @proxy.send(method, *args)
44
48
  end
45
49
  end
@@ -7,7 +7,7 @@ shared_examples_for 'all sessions' do
7
7
  end
8
8
 
9
9
  it 'should add document to connection' do
10
- connection.should have(1).adds
10
+ expect(connection.adds.size).to eq(1)
11
11
  end
12
12
  end
13
13
 
@@ -17,11 +17,11 @@ shared_examples_for 'all sessions' do
17
17
  end
18
18
 
19
19
  it 'should add document to connection' do
20
- connection.should have(1).adds
20
+ expect(connection.adds.size).to eq(1)
21
21
  end
22
22
 
23
23
  it 'should commit' do
24
- connection.should have(1).commits
24
+ expect(connection.commits.size).to eq(1)
25
25
  end
26
26
  end
27
27
 
@@ -31,27 +31,27 @@ shared_examples_for 'all sessions' do
31
31
  end
32
32
 
33
33
  it 'should commit' do
34
- connection.should have(1).commits
34
+ expect(connection.commits.size).to eq(1)
35
35
  end
36
36
  end
37
37
 
38
38
  context '#commit(bool)' do
39
39
  it 'should soft-commit if bool=true' do
40
40
  @session.commit(true)
41
- connection.should have(1).commits
42
- connection.should have(1).soft_commits
41
+ expect(connection.commits.size).to eq(1)
42
+ expect(connection.soft_commits.size).to eq(1)
43
43
  end
44
44
 
45
45
  it 'should hard-commit if bool=false' do
46
46
  @session.commit(false)
47
- connection.should have(1).commits
48
- connection.should have(0).soft_commits
47
+ expect(connection.commits.size).to eq(1)
48
+ expect(connection.soft_commits.size).to eq(0)
49
49
  end
50
50
 
51
51
  it 'should hard-commit if bool is not specified' do
52
52
  @session.commit
53
- connection.should have(1).commits
54
- connection.should have(0).soft_commits
53
+ expect(connection.commits.size).to eq(1)
54
+ expect(connection.soft_commits.size).to eq(0)
55
55
  end
56
56
  end
57
57
 
@@ -61,7 +61,7 @@ shared_examples_for 'all sessions' do
61
61
  end
62
62
 
63
63
  it 'should optimize' do
64
- connection.should have(1).optims
64
+ expect(connection.optims.size).to eq(1)
65
65
  end
66
66
  end
67
67
 
@@ -71,7 +71,7 @@ shared_examples_for 'all sessions' do
71
71
  end
72
72
 
73
73
  it 'should search' do
74
- connection.should have(1).searches
74
+ expect(connection.searches.size).to eq(1)
75
75
  end
76
76
  end
77
77
  end
@@ -97,31 +97,31 @@ describe 'Session' do
97
97
 
98
98
  it 'should open connection with defaults if nothing specified' do
99
99
  Sunspot.commit
100
- connection.opts[:url].should == 'http://127.0.0.1:8983/solr/default'
100
+ expect(connection.opts[:url]).to eq('http://127.0.0.1:8983/solr/default')
101
101
  end
102
102
 
103
103
  it 'should open a connection with custom host' do
104
104
  Sunspot.config.solr.url = 'http://127.0.0.1:8981/solr'
105
105
  Sunspot.commit
106
- connection.opts[:url].should == 'http://127.0.0.1:8981/solr'
106
+ expect(connection.opts[:url]).to eq('http://127.0.0.1:8981/solr')
107
107
  end
108
108
 
109
109
  it 'should open a connection with custom read timeout' do
110
110
  Sunspot.config.solr.read_timeout = 0.5
111
111
  Sunspot.commit
112
- connection.opts[:read_timeout].should == 0.5
112
+ expect(connection.opts[:read_timeout]).to eq(0.5)
113
113
  end
114
114
 
115
115
  it 'should open a connection with custom open timeout' do
116
116
  Sunspot.config.solr.open_timeout = 0.5
117
117
  Sunspot.commit
118
- connection.opts[:open_timeout].should == 0.5
118
+ expect(connection.opts[:open_timeout]).to eq(0.5)
119
119
  end
120
120
 
121
121
  it 'should open a connection through a provided proxy' do
122
122
  Sunspot.config.solr.proxy = 'http://proxy.com:1234'
123
123
  Sunspot.commit
124
- connection.opts[:proxy].should == 'http://proxy.com:1234'
124
+ expect(connection.opts[:proxy]).to eq('http://proxy.com:1234')
125
125
  end
126
126
  end
127
127
 
@@ -137,7 +137,7 @@ describe 'Session' do
137
137
  config.solr.url = 'http://127.0.0.1:8982/solr'
138
138
  end
139
139
  session.commit
140
- connection.opts[:url].should == 'http://127.0.0.1:8982/solr'
140
+ expect(connection.opts[:url]).to eq('http://127.0.0.1:8982/solr')
141
141
  end
142
142
  end
143
143
 
@@ -147,120 +147,120 @@ describe 'Session' do
147
147
  end
148
148
 
149
149
  it 'should start out not dirty' do
150
- @session.dirty?.should be_false
150
+ expect(@session.dirty?).to be(false)
151
151
  end
152
152
 
153
153
  it 'should start out not delete_dirty' do
154
- @session.delete_dirty?.should be_false
154
+ expect(@session.delete_dirty?).to be(false)
155
155
  end
156
156
 
157
157
  it 'should be dirty after adding an item' do
158
158
  @session.index(Post.new)
159
- @session.dirty?.should be_true
159
+ expect(@session.dirty?).to be(true)
160
160
  end
161
161
 
162
162
  it 'should be not be delete_dirty after adding an item' do
163
163
  @session.index(Post.new)
164
- @session.delete_dirty?.should be_false
164
+ expect(@session.delete_dirty?).to be(false)
165
165
  end
166
166
 
167
167
  it 'should be dirty after deleting an item' do
168
168
  @session.remove(Post.new)
169
- @session.dirty?.should be_true
169
+ expect(@session.dirty?).to be(true)
170
170
  end
171
171
 
172
172
  it 'should be delete_dirty after deleting an item' do
173
173
  @session.remove(Post.new)
174
- @session.delete_dirty?.should be_true
174
+ expect(@session.delete_dirty?).to be(true)
175
175
  end
176
176
 
177
177
  it 'should be dirty after a remove_all for a class' do
178
178
  @session.remove_all(Post)
179
- @session.dirty?.should be_true
179
+ expect(@session.dirty?).to be(true)
180
180
  end
181
181
 
182
182
  it 'should be delete_dirty after a remove_all for a class' do
183
183
  @session.remove_all(Post)
184
- @session.delete_dirty?.should be_true
184
+ expect(@session.delete_dirty?).to be(true)
185
185
  end
186
186
 
187
187
  it 'should be dirty after a global remove_all' do
188
188
  @session.remove_all
189
- @session.dirty?.should be_true
189
+ expect(@session.dirty?).to be(true)
190
190
  end
191
191
 
192
192
  it 'should be delete_dirty after a global remove_all' do
193
193
  @session.remove_all
194
- @session.delete_dirty?.should be_true
194
+ expect(@session.delete_dirty?).to be(true)
195
195
  end
196
196
 
197
197
  it 'should not be dirty after a commit' do
198
198
  @session.index(Post.new)
199
199
  @session.commit
200
- @session.dirty?.should be_false
200
+ expect(@session.dirty?).to be(false)
201
201
  end
202
202
 
203
203
  it 'should not be dirty after an optimize' do
204
204
  @session.index(Post.new)
205
205
  @session.optimize
206
- @session.dirty?.should be_false
206
+ expect(@session.dirty?).to be(false)
207
207
  end
208
208
 
209
209
  it 'should not be delete_dirty after a commit' do
210
210
  @session.remove(Post.new)
211
211
  @session.commit
212
- @session.delete_dirty?.should be_false
212
+ expect(@session.delete_dirty?).to be(false)
213
213
  end
214
214
 
215
215
  it 'should not be delete_dirty after an optimize' do
216
216
  @session.remove(Post.new)
217
217
  @session.optimize
218
- @session.delete_dirty?.should be_false
218
+ expect(@session.delete_dirty?).to be(false)
219
219
  end
220
220
 
221
221
  it 'should not commit when commit_if_dirty called on clean session' do
222
222
  @session.commit_if_dirty
223
- connection.should have(0).commits
223
+ expect(connection.commits.size).to eq(0)
224
224
  end
225
225
 
226
226
  it 'should not commit when commit_if_delete_dirty called on clean session' do
227
227
  @session.commit_if_delete_dirty
228
- connection.should have(0).commits
228
+ expect(connection.commits.size).to eq(0)
229
229
  end
230
230
 
231
231
  it 'should hard commit when commit_if_dirty called on dirty session' do
232
232
  @session.index(Post.new)
233
233
  @session.commit_if_dirty
234
- connection.should have(1).commits
234
+ expect(connection.commits.size).to eq(1)
235
235
  end
236
236
 
237
237
  it 'should soft commit when commit_if_dirty called on dirty session' do
238
238
  @session.index(Post.new)
239
239
  @session.commit_if_dirty(true)
240
- connection.should have(1).commits
241
- connection.should have(1).soft_commits
240
+ expect(connection.commits.size).to eq(1)
241
+ expect(connection.soft_commits.size).to eq(1)
242
242
  end
243
243
 
244
244
  it 'should hard commit when commit_if_delete_dirty called on delete_dirty session' do
245
245
  @session.remove(Post.new)
246
246
  @session.commit_if_delete_dirty
247
- connection.should have(1).commits
247
+ expect(connection.commits.size).to eq(1)
248
248
  end
249
249
 
250
250
  it 'should soft commit when commit_if_delete_dirty called on delete_dirty session' do
251
251
  @session.remove(Post.new)
252
252
  @session.commit_if_delete_dirty(true)
253
- connection.should have(1).commits
254
- connection.should have(1).soft_commits
253
+ expect(connection.commits.size).to eq(1)
254
+ expect(connection.soft_commits.size).to eq(1)
255
255
  end
256
256
  end
257
257
 
258
258
  context 'session proxy' do
259
259
  it 'should send messages to manually assigned session proxy' do
260
- stub_session = stub('session')
260
+ stub_session = double('session')
261
261
  Sunspot.session = stub_session
262
262
  post = Post.new
263
- stub_session.should_receive(:index).with(post)
263
+ expect(stub_session).to receive(:index).with(post)
264
264
  Sunspot.index(post)
265
265
  Sunspot.reset!
266
266
  end