sunspot_matchers 2.2.0.2 → 2.2.0.3
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/sunspot_matchers/matchers.rb +1 -1
- data/lib/sunspot_matchers/test_helper.rb +3 -3
- data/lib/sunspot_matchers/version.rb +1 -1
- data/spec/sunspot_matchers_spec.rb +16 -0
- data/test/sunspot_matchers_test.rb +17 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71be1abd82eb01fa8a46f8e653d029a8e0c70bd2
|
4
|
+
data.tar.gz: bacebe7d1bd6355569949a37c785855a7559858e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c9c890cd0810b7024f63886cc287afae42a61f35bc3d242418ac6df3940674355bb920344728bf726d94ababea5dc5d759a2afd573a3988c1d2e9d09281e912
|
7
|
+
data.tar.gz: 8a58d1766e222075acdf3302cc49f97a78abb5377c2d0cffdf88718e50527c8461b54025a5337bcd7fdb362ba5f57973548ad4e9601e18c80948cdea7e144a94
|
data/Gemfile.lock
CHANGED
@@ -9,7 +9,7 @@ module SunspotMatchers
|
|
9
9
|
def initialize(session, method, *args, &block)
|
10
10
|
@session = session
|
11
11
|
@method = method
|
12
|
-
@args = [*args, block]
|
12
|
+
@args = (block.nil? ? args : [*args, block])
|
13
13
|
end
|
14
14
|
|
15
15
|
def get_matcher
|
@@ -33,7 +33,7 @@ module SunspotMatchers
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
|
36
|
+
|
37
37
|
class BeASearchForSession
|
38
38
|
def initialize(session, expected_class)
|
39
39
|
@session = session
|
@@ -74,7 +74,7 @@ module SunspotMatchers
|
|
74
74
|
matcher = HaveSearchParamsForSession.new(session, method, *args, &block).get_matcher
|
75
75
|
assert !matcher.match?, matcher.unexpected_match_error_message
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
def assert_is_search_for(session, expected_class)
|
79
79
|
matcher = BeASearchForSession.new(session, expected_class)
|
80
80
|
assert matcher.match?, matcher.failure_message_for_should
|
@@ -52,6 +52,22 @@ describe "Sunspot Matchers" do
|
|
52
52
|
expect(Sunspot.session.searches.last).to have_search_params(:keywords, 'bad pizza')
|
53
53
|
end
|
54
54
|
|
55
|
+
context 'when the search arg is nil' do
|
56
|
+
before do
|
57
|
+
Sunspot.search(Post) { with(:published_at, Time.now) }
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'respects expectations on nil parameters' do
|
61
|
+
expect {
|
62
|
+
expect(Sunspot.session.searches.first).to have_search_params(:with, :published_at, nil)
|
63
|
+
}.to raise_error RSpec::Expectations::ExpectationNotMetError
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'allows negated expectation on nil' do
|
67
|
+
expect(Sunspot.session.searches.last).not_to have_search_params(:with, :published_at, nil)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
55
71
|
describe "keyword/fulltext matcher" do
|
56
72
|
it "matches if search matches" do
|
57
73
|
Sunspot.search(Post) do
|
@@ -47,7 +47,21 @@ class SunspotMatchersTest < MiniTest::Unit::TestCase
|
|
47
47
|
end
|
48
48
|
assert_has_search_params Sunspot.session, :keywords, 'great pizza'
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
|
+
def test_respects_expectation_on_nil
|
52
|
+
Sunspot.search(Post) do
|
53
|
+
with(:published_at, Time.now)
|
54
|
+
end
|
55
|
+
assert_raises(MiniTest::Assertion) { assert_has_search_params(Sunspot.session, :with, :published_at, nil) }
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_respects_negated_expectation_on_nil
|
59
|
+
Sunspot.search(Post) do
|
60
|
+
with(:published_at, Time.now)
|
61
|
+
end
|
62
|
+
assert_has_no_search_params Sunspot.session, :with, :published_at, nil
|
63
|
+
end
|
64
|
+
|
51
65
|
def test_match_keywords
|
52
66
|
Sunspot.search(Post) do
|
53
67
|
keywords 'great pizza'
|
@@ -699,11 +713,11 @@ class SunspotMatchersTest < MiniTest::Unit::TestCase
|
|
699
713
|
assert_is_search_for Sunspot.session, Blog
|
700
714
|
assert_is_not_search_for Sunspot.session, Person
|
701
715
|
end
|
702
|
-
|
716
|
+
|
703
717
|
def test_be_a_search_for_multiple_searches
|
704
718
|
Sunspot.search(Post) { keywords 'great pizza' }
|
705
719
|
Sunspot.search(Blog) { keywords 'bad pizza' }
|
706
720
|
assert_is_search_for Sunspot.session.searches.first, Post
|
707
721
|
assert_is_search_for Sunspot.session.searches.last, Blog
|
708
722
|
end
|
709
|
-
end
|
723
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sunspot_matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.0.
|
4
|
+
version: 2.2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joseph Palermo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|