rspec-solr 0.1.3 → 0.1.4
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.
data/.travis.yml
CHANGED
@@ -39,7 +39,7 @@ module RSpec
|
|
39
39
|
if @before_expected
|
40
40
|
"expected #{@actual.inspect} to #{name_to_sentence} #{doc_label_str(@expected)}#{expected_to_sentence} before #{doc_label_str(@before_expected)} matching #{@before_expected.inspect}"
|
41
41
|
elsif @min_for_last_matching_doc_pos
|
42
|
-
"expected each of the first #{@min_for_last_matching_doc_pos.to_s} documents to #{name_to_sentence}#{expected_to_sentence}: #{@actual.inspect}"
|
42
|
+
"expected each of the first #{@min_for_last_matching_doc_pos.to_s} documents to #{name_to_sentence}#{expected_to_sentence} in response: #{@actual.inspect}"
|
43
43
|
elsif @max_doc_position
|
44
44
|
"expected #{@actual.inspect} to #{name_to_sentence} #{doc_label_str(@expected)}#{expected_to_sentence} in first #{@max_doc_position.to_s} results"
|
45
45
|
else
|
@@ -53,7 +53,7 @@ module RSpec
|
|
53
53
|
if @before_expected
|
54
54
|
"expected #{@actual.inspect} not to #{name_to_sentence} #{doc_label_str(@expected)}#{expected_to_sentence} before #{doc_label_str(@before_expected)} matching #{@before_expected.inspect}"
|
55
55
|
elsif @min_for_last_matching_doc_pos
|
56
|
-
"expected some of the first #{@min_for_last_matching_doc_pos.to_s} documents not to #{name_to_sentence}#{expected_to_sentence}: #{@actual.inspect}"
|
56
|
+
"expected some of the first #{@min_for_last_matching_doc_pos.to_s} documents not to #{name_to_sentence}#{expected_to_sentence} in response: #{@actual.inspect}"
|
57
57
|
elsif @max_doc_position
|
58
58
|
"expected #{@actual.inspect} not to #{name_to_sentence} #{doc_label_str(@expected)}#{expected_to_sentence} in first #{@max_doc_position.to_s} results"
|
59
59
|
else
|
@@ -41,9 +41,8 @@ class RSpecSolr
|
|
41
41
|
def has_document?(expected_doc, max_doc_position = nil, all_must_match = nil)
|
42
42
|
if expected_doc.is_a?(Hash)
|
43
43
|
if all_must_match
|
44
|
-
first_non_match = docs.find_index { |doc|
|
45
|
-
|
46
|
-
} >= max_doc_position
|
44
|
+
first_non_match = docs.find_index { |doc| !doc_matches_all_criteria(doc, expected_doc) }
|
45
|
+
(first_non_match ? first_non_match >= max_doc_position : true)
|
47
46
|
else
|
48
47
|
# we are happy if any doc meets all of our expectations
|
49
48
|
docs.any? { |doc|
|
@@ -75,7 +74,7 @@ class RSpecSolr
|
|
75
74
|
# a doc's fld values can be a String or an Array
|
76
75
|
case exp_val
|
77
76
|
when Regexp
|
78
|
-
Array(doc[exp_fname]).any? { |val| val =~ exp_val }
|
77
|
+
return true if Array(doc[exp_fname]).any? { |val| val =~ exp_val }
|
79
78
|
else
|
80
79
|
Array(doc[exp_fname]).include?(exp_val)
|
81
80
|
end
|
data/lib/rspec-solr/version.rb
CHANGED
@@ -364,6 +364,7 @@ describe RSpecSolr do
|
|
364
364
|
it "passes if Solr document in response matches regex in named field" do
|
365
365
|
@solr_resp_5_docs.should include("id" => /\d{3}/)
|
366
366
|
@solr_resp_5_docs.should include("fld" => /^va/) # 2 docs match
|
367
|
+
@solr_resp_5_docs.should include("fld" => /Va/i) # 2 docs match
|
367
368
|
end
|
368
369
|
it "passes if single value expectation is expressed as an Array" do
|
369
370
|
@solr_resp_5_docs.should include("id" => [/111/])
|
@@ -12,6 +12,11 @@ describe RSpecSolr do
|
|
12
12
|
@solr_resp.should include("fld" => "val").in_each_of_first(2).documents
|
13
13
|
@solr_resp.should include("fld" => "val").in_each_of_first(2).results
|
14
14
|
end
|
15
|
+
it "passes when all docs in range meet regex criteria" do
|
16
|
+
@solr_resp.should include("fld" => /val/).in_each_of_first(2)
|
17
|
+
@solr_resp.should include("fld" => /al/).in_each_of_first(2)
|
18
|
+
@solr_resp.should include("fld" => /Val/i).in_each_of_first(2)
|
19
|
+
end
|
15
20
|
it "fails when doc in range doesn't meet criteria" do
|
16
21
|
lambda {
|
17
22
|
@solr_resp.should include("fld2" => "val2").in_each_of_first(2)
|
@@ -20,6 +25,14 @@ describe RSpecSolr do
|
|
20
25
|
@solr_resp.should include("fld" => "val").in_each_of_first(3)
|
21
26
|
}.should fail_matching('expected each of the first 3 documents to include {"fld"=>"val"}')
|
22
27
|
end
|
28
|
+
it "fails when doc in range doesn't meet regex criteria" do
|
29
|
+
lambda {
|
30
|
+
@solr_resp.should include("fld2" => /l2/).in_each_of_first(2)
|
31
|
+
}.should fail_matching('expected each of the first 2 documents to include {"fld2"=>/l2/}')
|
32
|
+
lambda {
|
33
|
+
@solr_resp.should include("fld" => /al/).in_each_of_first(3)
|
34
|
+
}.should fail_matching('expected each of the first 3 documents to include {"fld"=>/al/}')
|
35
|
+
end
|
23
36
|
end
|
24
37
|
context "should_NOT" do
|
25
38
|
it "fails when all docs in range meet criteria" do
|
@@ -33,10 +46,25 @@ describe RSpecSolr do
|
|
33
46
|
@solr_resp.should_not include("fld" => "val").in_each_of_first(2).results
|
34
47
|
}.should fail_matching('expected some of the first 2 documents not to include {"fld"=>"val"}')
|
35
48
|
end
|
49
|
+
it "fails when all docs in range meet regex criteria" do
|
50
|
+
lambda {
|
51
|
+
@solr_resp.should_not include("fld" => /val/).in_each_of_first(2)
|
52
|
+
}.should fail_matching('expected some of the first 2 documents not to include {"fld"=>/val/}')
|
53
|
+
lambda {
|
54
|
+
@solr_resp.should_not include("fld" => /al/).in_each_of_first(2)
|
55
|
+
}.should fail_matching('expected some of the first 2 documents not to include {"fld"=>/al/}')
|
56
|
+
lambda {
|
57
|
+
@solr_resp.should_not include("fld" => /Val/i).in_each_of_first(2)
|
58
|
+
}.should fail_matching('expected some of the first 2 documents not to include {"fld"=>/Val/i}')
|
59
|
+
end
|
36
60
|
it "passes when doc in range doesn't meet criteria" do
|
37
61
|
@solr_resp.should_not include("fld" => "val").in_each_of_first(3)
|
38
62
|
@solr_resp.should_not include("fld2" => "val2").in_each_of_first(2)
|
39
63
|
end
|
64
|
+
it "passes when doc in range doesn't meet regex criteria" do
|
65
|
+
@solr_resp.should_not include("fld2" => /l2/).in_each_of_first(2)
|
66
|
+
@solr_resp.should_not include("fld" => /al/).in_each_of_first(3)
|
67
|
+
end
|
40
68
|
end
|
41
69
|
it "should expect a Hash for the include" do
|
42
70
|
expect {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-solr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-10-
|
13
|
+
date: 2012-10-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -178,7 +178,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
178
178
|
version: '0'
|
179
179
|
segments:
|
180
180
|
- 0
|
181
|
-
hash:
|
181
|
+
hash: 3247708301967459464
|
182
182
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
183
183
|
none: false
|
184
184
|
requirements:
|
@@ -187,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
187
|
version: '0'
|
188
188
|
segments:
|
189
189
|
- 0
|
190
|
-
hash:
|
190
|
+
hash: 3247708301967459464
|
191
191
|
requirements: []
|
192
192
|
rubyforge_project:
|
193
193
|
rubygems_version: 1.8.24
|