elasticsearch-api 0.4.0 → 0.4.1

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 (115) hide show
  1. data/README.md +8 -2
  2. data/Rakefile +15 -1
  3. data/elasticsearch-api.gemspec +12 -0
  4. data/lib/{elasticsearch-api → elasticsearch-api.rb} +0 -0
  5. data/lib/elasticsearch/api.rb +9 -0
  6. data/lib/elasticsearch/api/actions/bulk.rb +9 -9
  7. data/lib/elasticsearch/api/actions/cluster/health.rb +12 -12
  8. data/lib/elasticsearch/api/actions/cluster/node_hot_threads.rb +9 -9
  9. data/lib/elasticsearch/api/actions/cluster/node_info.rb +16 -16
  10. data/lib/elasticsearch/api/actions/cluster/node_shutdown.rb +7 -7
  11. data/lib/elasticsearch/api/actions/cluster/node_stats.rb +16 -18
  12. data/lib/elasticsearch/api/actions/cluster/reroute.rb +4 -6
  13. data/lib/elasticsearch/api/actions/cluster/state.rb +12 -12
  14. data/lib/elasticsearch/api/actions/count.rb +9 -9
  15. data/lib/elasticsearch/api/actions/delete.rb +16 -13
  16. data/lib/elasticsearch/api/actions/delete_by_query.rb +15 -14
  17. data/lib/elasticsearch/api/actions/exists.rb +13 -11
  18. data/lib/elasticsearch/api/actions/explain.rb +28 -17
  19. data/lib/elasticsearch/api/actions/get.rb +20 -11
  20. data/lib/elasticsearch/api/actions/get_source.rb +23 -11
  21. data/lib/elasticsearch/api/actions/index.rb +20 -18
  22. data/lib/elasticsearch/api/actions/indices/analyze.rb +12 -13
  23. data/lib/elasticsearch/api/actions/indices/clear_cache.rb +15 -15
  24. data/lib/elasticsearch/api/actions/indices/close.rb +5 -6
  25. data/lib/elasticsearch/api/actions/indices/create.rb +5 -6
  26. data/lib/elasticsearch/api/actions/indices/delete.rb +5 -6
  27. data/lib/elasticsearch/api/actions/indices/delete_alias.rb +5 -6
  28. data/lib/elasticsearch/api/actions/indices/delete_mapping.rb +1 -1
  29. data/lib/elasticsearch/api/actions/indices/delete_template.rb +5 -6
  30. data/lib/elasticsearch/api/actions/indices/delete_warmer.rb +1 -1
  31. data/lib/elasticsearch/api/actions/indices/exists_alias.rb +5 -6
  32. data/lib/elasticsearch/api/actions/indices/exists_type.rb +5 -6
  33. data/lib/elasticsearch/api/actions/indices/flush.rb +9 -9
  34. data/lib/elasticsearch/api/actions/indices/get_alias.rb +5 -6
  35. data/lib/elasticsearch/api/actions/indices/get_aliases.rb +5 -6
  36. data/lib/elasticsearch/api/actions/indices/get_mapping.rb +1 -1
  37. data/lib/elasticsearch/api/actions/indices/get_settings.rb +1 -1
  38. data/lib/elasticsearch/api/actions/indices/get_template.rb +1 -2
  39. data/lib/elasticsearch/api/actions/indices/get_warmer.rb +1 -1
  40. data/lib/elasticsearch/api/actions/indices/open.rb +5 -6
  41. data/lib/elasticsearch/api/actions/indices/optimize.rb +12 -12
  42. data/lib/elasticsearch/api/actions/indices/put_alias.rb +5 -6
  43. data/lib/elasticsearch/api/actions/indices/put_mapping.rb +5 -7
  44. data/lib/elasticsearch/api/actions/indices/put_settings.rb +1 -1
  45. data/lib/elasticsearch/api/actions/indices/put_template.rb +5 -7
  46. data/lib/elasticsearch/api/actions/indices/refresh.rb +5 -6
  47. data/lib/elasticsearch/api/actions/indices/segments.rb +5 -6
  48. data/lib/elasticsearch/api/actions/indices/snapshot_index.rb +5 -6
  49. data/lib/elasticsearch/api/actions/indices/stats.rb +23 -23
  50. data/lib/elasticsearch/api/actions/indices/status.rb +8 -8
  51. data/lib/elasticsearch/api/actions/indices/update_aliases.rb +4 -5
  52. data/lib/elasticsearch/api/actions/indices/validate_query.rb +11 -9
  53. data/lib/elasticsearch/api/actions/mget.rb +21 -11
  54. data/lib/elasticsearch/api/actions/mlt.rb +28 -24
  55. data/lib/elasticsearch/api/actions/msearch.rb +4 -5
  56. data/lib/elasticsearch/api/actions/percolate.rb +7 -6
  57. data/lib/elasticsearch/api/actions/scroll.rb +5 -6
  58. data/lib/elasticsearch/api/actions/search.rb +37 -30
  59. data/lib/elasticsearch/api/actions/suggest.rb +8 -8
  60. data/lib/elasticsearch/api/actions/update.rb +24 -20
  61. data/lib/elasticsearch/api/utils.rb +44 -6
  62. data/lib/elasticsearch/api/version.rb +1 -1
  63. data/test/integration/yaml_test_runner.rb +4 -5
  64. data/test/test_helper.rb +1 -1
  65. data/test/unit/bulk_test.rb +9 -0
  66. data/test/unit/cluster/node_hot_threads_test.rb +9 -0
  67. data/test/unit/create_document_test.rb +9 -0
  68. data/test/unit/delete_document_test.rb +16 -1
  69. data/test/unit/exists_document_test.rb +9 -0
  70. data/test/unit/explain_document_test.rb +9 -0
  71. data/test/unit/get_document_source_test.rb +10 -1
  72. data/test/unit/get_document_test.rb +16 -1
  73. data/test/unit/index_document_test.rb +15 -0
  74. data/test/unit/indices/analyze_test.rb +9 -0
  75. data/test/unit/indices/clear_cache_test.rb +9 -0
  76. data/test/unit/indices/close_test.rb +9 -0
  77. data/test/unit/indices/create_test.rb +9 -0
  78. data/test/unit/indices/delete_alias_test.rb +9 -0
  79. data/test/unit/indices/delete_mapping_test.rb +9 -0
  80. data/test/unit/indices/delete_template_test.rb +9 -0
  81. data/test/unit/indices/delete_test.rb +9 -0
  82. data/test/unit/indices/delete_warmer_test.rb +9 -0
  83. data/test/unit/indices/exists_alias_test.rb +9 -0
  84. data/test/unit/indices/exists_test.rb +9 -0
  85. data/test/unit/indices/exists_type_test.rb +9 -0
  86. data/test/unit/indices/flush_test.rb +9 -0
  87. data/test/unit/indices/get_alias_test.rb +9 -0
  88. data/test/unit/indices/get_aliases_test.rb +9 -0
  89. data/test/unit/indices/get_mapping_test.rb +9 -0
  90. data/test/unit/indices/get_settings_test.rb +9 -0
  91. data/test/unit/indices/get_template_test.rb +10 -6
  92. data/test/unit/indices/get_warmer_test.rb +9 -0
  93. data/test/unit/indices/open_test.rb +9 -0
  94. data/test/unit/indices/optimize_test.rb +9 -0
  95. data/test/unit/indices/put_alias_test.rb +9 -0
  96. data/test/unit/indices/put_mapping_test.rb +9 -0
  97. data/test/unit/indices/put_settings_test.rb +9 -0
  98. data/test/unit/indices/put_template_test.rb +9 -0
  99. data/test/unit/indices/put_warmer_test.rb +9 -0
  100. data/test/unit/indices/refresh_test.rb +9 -0
  101. data/test/unit/indices/segments_test.rb +9 -0
  102. data/test/unit/indices/snapshot_index_test.rb +9 -0
  103. data/test/unit/indices/stats_test.rb +9 -0
  104. data/test/unit/indices/status_test.rb +9 -0
  105. data/test/unit/indices/validate_query_test.rb +9 -0
  106. data/test/unit/mget_test.rb +9 -0
  107. data/test/unit/mlt_test.rb +9 -0
  108. data/test/unit/msearch_test.rb +9 -0
  109. data/test/unit/percolate_test.rb +9 -0
  110. data/test/unit/search_test.rb +16 -1
  111. data/test/unit/suggest_test.rb +9 -0
  112. data/test/unit/update_document_test.rb +16 -1
  113. data/test/unit/utils_test.rb +34 -5
  114. metadata +161 -44
  115. checksums.yaml +0 -7
@@ -8,7 +8,7 @@ require 'elasticsearch/transport/extensions/test_cluster'
8
8
 
9
9
  # Launch test cluster
10
10
  #
11
- Elasticsearch::TestCluster.start if ENV['SERVER']
11
+ Elasticsearch::TestCluster.start if ENV['SERVER'] and not Elasticsearch::TestCluster.running?
12
12
 
13
13
  # Register `at_exit` handler for server shutdown.
14
14
  # MUST be called before requiring `test/unit`.
@@ -44,7 +44,7 @@ module Shoulda
44
44
  module Context
45
45
  class Context
46
46
  def create_test_from_should_hash(should)
47
- test_name = ["test:", full_name, "--", "#{should[:name]}. "].flatten.join(' ').to_sym
47
+ test_name = ["test:", full_name, "|", "#{should[:name]}"].flatten.join(' ').to_sym
48
48
 
49
49
  if test_methods[test_unit_class][test_name.to_s] then
50
50
  raise DuplicateTestError, "'#{test_name}' is defined more than once."
@@ -76,7 +76,7 @@ module Elasticsearch
76
76
 
77
77
  module Utils
78
78
  def titleize(word)
79
- word.to_s.gsub(/[^\w]+/, ' ').gsub(/\b('?[a-z])/) { $1.capitalize }
79
+ word.to_s.gsub(/[^\w]+/, ' ').gsub(/\b('?[a-z])/) { $1.capitalize }.tr('_', ' ')
80
80
  end
81
81
 
82
82
  def symbolize_keys(object)
@@ -206,7 +206,6 @@ suites.each do |suite|
206
206
 
207
207
  files = Dir[suite.join('*.{yml,yaml}')]
208
208
  files.each do |file|
209
-
210
209
  tests = YAML.load_documents File.new(file)
211
210
 
212
211
  # Extract setup actions
@@ -220,7 +219,7 @@ suites.each do |suite|
220
219
 
221
220
  tests.each do |test|
222
221
  context '' do
223
- test_name = test.keys.first
222
+ test_name = test.keys.first.to_s + (ENV['QUIET'] ? '' : " | #{ANSI.ansi(file.gsub(PATH.to_s, ''), :bold)}")
224
223
  actions = test.values.first
225
224
 
226
225
  if reason = Runner.skip?(actions)
data/test/test_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  RUBY_1_8 = defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
2
2
 
3
- if RUBY_1_8
3
+ if RUBY_1_8 and not ENV['BUNDLE_GEMFILE']
4
4
  require 'rubygems'
5
5
  gem 'test-unit'
6
6
  end
@@ -78,6 +78,15 @@ module Elasticsearch
78
78
  subject.bulk :refresh => true, :body => []
79
79
  end
80
80
 
81
+ should "URL-escape the parts" do
82
+ subject.expects(:perform_request).with do |method, url, params, body|
83
+ assert_equal 'foo%5Ebar/_bulk', url
84
+ true
85
+ end.returns(FakeResponse.new)
86
+
87
+ subject.bulk :index => 'foo^bar', :body => []
88
+ end
89
+
81
90
  end
82
91
 
83
92
  end
@@ -28,6 +28,15 @@ module Elasticsearch
28
28
  subject.cluster.node_hot_threads :node_id => 'foo'
29
29
  end
30
30
 
31
+ should "URL-escape the parts" do
32
+ subject.expects(:perform_request).with do |method, url, params, body|
33
+ assert_equal '_cluster/nodes/foo%5Ebar/hot_threads', url
34
+ true
35
+ end.returns(FakeResponse.new)
36
+
37
+ subject.cluster.node_hot_threads :node_id => 'foo^bar'
38
+ end
39
+
31
40
  end
32
41
 
33
42
  end
@@ -31,6 +31,15 @@ module Elasticsearch
31
31
 
32
32
  subject.create :index => 'foo', :type => 'bar', :id => '123', :body => {:foo => 'bar'}
33
33
  end
34
+
35
+ should "URL-escape the parts" do
36
+ subject.expects(:perform_request).with do |method, url, params, body|
37
+ assert_equal 'foo/bar%2Fbam/123', url
38
+ true
39
+ end.returns(FakeResponse.new)
40
+
41
+ subject.create :index => 'foo', :type => 'bar/bam', :id => '123', :body => {}
42
+ end
34
43
  end
35
44
 
36
45
  end
@@ -47,11 +47,26 @@ module Elasticsearch
47
47
  subject.delete :index => 'foo', :type => 'bar', :id => '1', :routing => 'abc123'
48
48
  end
49
49
 
50
+ should "validate URL parameters" do
51
+ assert_raise ArgumentError do
52
+ subject.delete :index => 'foo', :type => 'bar', :id => '1', :qwertypoiuy => 'asdflkjhg'
53
+ end
54
+ end
55
+
56
+ should "URL-escape the parts" do
57
+ subject.expects(:perform_request).with do |method, url, params, body|
58
+ assert_equal 'foo%5Ebar/bar%2Fbam/1', url
59
+ true
60
+ end.returns(FakeResponse.new)
61
+
62
+ subject.delete :index => 'foo^bar', :type => 'bar/bam', :id => 1
63
+ end
64
+
50
65
  should "catch a NotFound exception with the ignore parameter" do
51
66
  subject.expects(:perform_request).raises(NotFound)
52
67
 
53
68
  assert_nothing_raised do
54
- subject.get :index => 'foo', :type => 'bar', :id => 'XXX', ignore: 404
69
+ subject.get :index => 'foo', :type => 'bar', :id => 'XXX', :ignore => 404
55
70
  end
56
71
  end
57
72
 
@@ -47,6 +47,15 @@ module Elasticsearch
47
47
  subject.exists :index => 'foo', :type => 'bar', :id => '1', :routing => 'abc123'
48
48
  end
49
49
 
50
+ should "URL-escape the parts" do
51
+ subject.expects(:perform_request).with do |method, url, params, body|
52
+ assert_equal 'foo/bar%2Fbam/1', url
53
+ true
54
+ end.returns(FakeResponse.new)
55
+
56
+ subject.exists :index => 'foo', :type => 'bar/bam', :id => '1'
57
+ end
58
+
50
59
  should "return true for successful response" do
51
60
  subject.expects(:perform_request).returns(FakeResponse.new 200, 'OK')
52
61
  assert_equal true, subject.exists(:index => 'foo', :type => 'bar', :id => '1')
@@ -57,6 +57,15 @@ module Elasticsearch
57
57
  subject.explain :index => 'foo', :type => 'bar', :id => 1, :body => { :query => { :match => {} } }
58
58
  end
59
59
 
60
+ should "URL-escape the parts" do
61
+ subject.expects(:perform_request).with do |method, url, params, body|
62
+ assert_equal 'foo%5Ebar/bar%2Fbam/1/_explain', url
63
+ true
64
+ end.returns(FakeResponse.new)
65
+
66
+ subject.explain :index => 'foo^bar', :type => 'bar/bam', :id => '1', :body => {}
67
+ end
68
+
60
69
  end
61
70
 
62
71
  end
@@ -47,11 +47,20 @@ module Elasticsearch
47
47
  subject.get_source :index => 'foo', :type => 'bar', :id => '1', :routing => 'abc123'
48
48
  end
49
49
 
50
+ should "URL-escape the parts" do
51
+ subject.expects(:perform_request).with do |method, url, params, body|
52
+ assert_equal 'foo%5Ebar/bar%2Fbam/1/_source', url
53
+ true
54
+ end.returns(FakeResponse.new)
55
+
56
+ subject.get_source :index => 'foo^bar', :type => 'bar/bam', :id => '1'
57
+ end
58
+
50
59
  should "catch a NotFound exception with the ignore parameter" do
51
60
  subject.expects(:perform_request).raises(NotFound)
52
61
 
53
62
  assert_nothing_raised do
54
- subject.get :index => 'foo', :type => 'bar', :id => 'XXX', ignore: 404
63
+ subject.get :index => 'foo', :type => 'bar', :id => 'XXX', :ignore => 404
55
64
  end
56
65
  end
57
66
 
@@ -47,11 +47,26 @@ module Elasticsearch
47
47
  subject.get :index => 'foo', :type => 'bar', :id => '1', :routing => 'abc123'
48
48
  end
49
49
 
50
+ should "URL-escape the parts" do
51
+ subject.expects(:perform_request).with do |method, url, params, body|
52
+ assert_equal 'foo%5Ebar/bar%2Fbam/1', url
53
+ true
54
+ end.returns(FakeResponse.new)
55
+
56
+ subject.exists :index => 'foo^bar', :type => 'bar/bam', :id => '1'
57
+ end
58
+
59
+ should "validate URL parameters" do
60
+ assert_raise ArgumentError do
61
+ subject.get :index => 'foo', :type => 'bar', :id => '1', :qwertypoiuy => 'asdflkjhg'
62
+ end
63
+ end
64
+
50
65
  should "catch a NotFound exception with the ignore parameter" do
51
66
  subject.expects(:perform_request).raises(NotFound)
52
67
 
53
68
  assert_nothing_raised do
54
- subject.get :index => 'foo', :type => 'bar', :id => 'XXX', ignore: 404
69
+ subject.get :index => 'foo', :type => 'bar', :id => 'XXX', :ignore => 404
55
70
  end
56
71
  end
57
72
 
@@ -41,6 +41,21 @@ module Elasticsearch
41
41
 
42
42
  subject.index :index => 'foo', :type => 'bar', :id => '123', :body => {:foo => 'bar'}
43
43
  end
44
+
45
+ should "URL-escape the parts" do
46
+ subject.expects(:perform_request).with do |method, url, params, body|
47
+ assert_equal 'foo/bar%2Fbam/123', url
48
+ true
49
+ end.returns(FakeResponse.new)
50
+
51
+ subject.index :index => 'foo', :type => 'bar/bam', :id => '123', :body => {}
52
+ end
53
+
54
+ should "validate URL parameters" do
55
+ assert_raise ArgumentError do
56
+ subject.index :index => 'foo', :type => 'bar/bam', :id => '123', :body => {}, :qwertypoiuy => 'asdflkjhg'
57
+ end
58
+ end
44
59
  end
45
60
 
46
61
  context "Creating a document" do
@@ -60,6 +60,15 @@ module Elasticsearch
60
60
  subject.indices.analyze :text => 'Test', :tokenizer => 'whitespace', :filters => ['foo,bar']
61
61
  end
62
62
 
63
+ should "URL-escape the parts" do
64
+ subject.expects(:perform_request).with do |method, url, params, body|
65
+ assert_equal 'foo%5Ebar/_analyze', url
66
+ true
67
+ end.returns(FakeResponse.new)
68
+
69
+ subject.indices.analyze :index => 'foo^bar', :text => 'Test'
70
+ end
71
+
63
72
  end
64
73
 
65
74
  end
@@ -38,6 +38,15 @@ module Elasticsearch
38
38
  subject.indices.clear_cache :field_data => true
39
39
  end
40
40
 
41
+ should "URL-escape the parts" do
42
+ subject.expects(:perform_request).with do |method, url, params, body|
43
+ assert_equal 'foo%5Ebar/_cache/clear', url
44
+ true
45
+ end.returns(FakeResponse.new)
46
+
47
+ subject.indices.clear_cache :index => 'foo^bar'
48
+ end
49
+
41
50
  end
42
51
 
43
52
  end
@@ -35,6 +35,15 @@ module Elasticsearch
35
35
  subject.indices.close :index => 'foo', :timeout => '1s'
36
36
  end
37
37
 
38
+ should "URL-escape the parts" do
39
+ subject.expects(:perform_request).with do |method, url, params, body|
40
+ assert_equal 'foo%5Ebar/_close', url
41
+ true
42
+ end.returns(FakeResponse.new)
43
+
44
+ subject.indices.close :index => 'foo^bar'
45
+ end
46
+
38
47
  end
39
48
 
40
49
  end
@@ -35,6 +35,15 @@ module Elasticsearch
35
35
  subject.indices.create :index => 'foo', :timeout => '1s'
36
36
  end
37
37
 
38
+ should "URL-escape the parts" do
39
+ subject.expects(:perform_request).with do |method, url, params, body|
40
+ assert_equal 'foo%5Ebar', url
41
+ true
42
+ end.returns(FakeResponse.new)
43
+
44
+ subject.indices.create :index => 'foo^bar'
45
+ end
46
+
38
47
  end
39
48
 
40
49
  end
@@ -31,6 +31,15 @@ module Elasticsearch
31
31
  subject.indices.delete_alias :index => 'foo', :name => 'bar'
32
32
  end
33
33
 
34
+ should "URL-escape the parts" do
35
+ subject.expects(:perform_request).with do |method, url, params, body|
36
+ assert_equal 'foo%5Ebar/_alias/bar%2Fbam', url
37
+ true
38
+ end.returns(FakeResponse.new)
39
+
40
+ subject.indices.delete_alias :index => 'foo^bar', :name => 'bar/bam'
41
+ end
42
+
34
43
  end
35
44
 
36
45
  end
@@ -40,6 +40,15 @@ module Elasticsearch
40
40
  subject.indices.delete_mapping :index => ['foo','bar'], :type => 'baz'
41
41
  end
42
42
 
43
+ should "URL-escape the parts" do
44
+ subject.expects(:perform_request).with do |method, url, params, body|
45
+ assert_equal 'foo%5Ebar/bar%2Fbam', url
46
+ true
47
+ end.returns(FakeResponse.new)
48
+
49
+ subject.indices.delete_mapping :index => 'foo^bar', :type => 'bar/bam'
50
+ end
51
+
43
52
  end
44
53
 
45
54
  end
@@ -19,6 +19,15 @@ module Elasticsearch
19
19
  subject.indices.delete_template :name => 'foo'
20
20
  end
21
21
 
22
+ should "URL-escape the parts" do
23
+ subject.expects(:perform_request).with do |method, url, params, body|
24
+ assert_equal '_template/foo%5Ebar', url
25
+ true
26
+ end.returns(FakeResponse.new)
27
+
28
+ subject.indices.delete_template :name => 'foo^bar'
29
+ end
30
+
22
31
  end
23
32
 
24
33
  end
@@ -38,6 +38,15 @@ module Elasticsearch
38
38
  subject.indices.delete :index => 'foo', :timeout => '1s'
39
39
  end
40
40
 
41
+ should "URL-escape the parts" do
42
+ subject.expects(:perform_request).with do |method, url, params, body|
43
+ assert_equal 'foo%5Ebar', url
44
+ true
45
+ end.returns(FakeResponse.new)
46
+
47
+ subject.indices.delete :index => 'foo^bar'
48
+ end
49
+
41
50
  end
42
51
 
43
52
  end
@@ -52,6 +52,15 @@ module Elasticsearch
52
52
  subject.indices.delete_warmer :index => 'foo', :name => ['bar', 'baz']
53
53
  end
54
54
 
55
+ should "URL-escape the parts" do
56
+ subject.expects(:perform_request).with do |method, url, params, body|
57
+ assert_equal 'foo%5Ebar/_warmer/bar%2Fbam', url
58
+ true
59
+ end.returns(FakeResponse.new)
60
+
61
+ subject.indices.delete_warmer :index => 'foo^bar', :name => 'bar/bam'
62
+ end
63
+
55
64
  end
56
65
 
57
66
  end
@@ -34,6 +34,15 @@ module Elasticsearch
34
34
  subject.indices.exists_alias :index => ['foo','bar'], :name => 'bam'
35
35
  end
36
36
 
37
+ should "URL-escape the parts" do
38
+ subject.expects(:perform_request).with do |method, url, params, body|
39
+ assert_equal 'foo%5Ebar/_alias/bar%2Fbam', url
40
+ true
41
+ end.returns(FakeResponse.new)
42
+
43
+ subject.indices.exists_alias :index => 'foo^bar', :name => 'bar/bam'
44
+ end
45
+
37
46
  should "return true for successful response" do
38
47
  subject.expects(:perform_request).returns(FakeResponse.new 200, 'OK')
39
48
  assert_equal true, subject.indices.exists_alias(:name => 'foo')
@@ -28,6 +28,15 @@ module Elasticsearch
28
28
  subject.indices.exists(:index => ['foo', 'bar'])
29
29
  end
30
30
 
31
+ should "URL-escape the parts" do
32
+ subject.expects(:perform_request).with do |method, url, params, body|
33
+ assert_equal 'foo%5Ebar,bar%2Fbam', url
34
+ true
35
+ end.returns(FakeResponse.new)
36
+
37
+ subject.indices.exists :index => 'foo^bar,bar/bam'
38
+ end
39
+
31
40
  should "return true for successful response" do
32
41
  subject.expects(:perform_request).returns(FakeResponse.new 200, 'OK')
33
42
  assert_equal true, subject.indices.exists(:index => 'foo')
@@ -28,6 +28,15 @@ module Elasticsearch
28
28
  subject.indices.exists_type :index => ['foo','bar'], :type => 'bam'
29
29
  end
30
30
 
31
+ should "URL-escape the parts" do
32
+ subject.expects(:perform_request).with do |method, url, params, body|
33
+ assert_equal 'foo%5Ebar/bar%2Fbam', url
34
+ true
35
+ end.returns(FakeResponse.new)
36
+
37
+ subject.indices.exists_type :index => 'foo^bar', :type => 'bar/bam'
38
+ end
39
+
31
40
  should "return true for successful response" do
32
41
  subject.expects(:perform_request).returns(FakeResponse.new 200, 'OK')
33
42
  assert_equal true, subject.indices.exists_type(:index => 'foo', :type => 'bar')