sunspot_matchers 2.2.0.2 → 2.2.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 93ef209cdf1b1551de2677ab1aae74fbecc86c79
4
- data.tar.gz: c8ea87d0e981d7c657aab10e163049ac72183fcb
3
+ metadata.gz: 71be1abd82eb01fa8a46f8e653d029a8e0c70bd2
4
+ data.tar.gz: bacebe7d1bd6355569949a37c785855a7559858e
5
5
  SHA512:
6
- metadata.gz: 0a37bd7f78bc341cb1ae84d827ff11596d9791610cfbda858dcac5817e6f29a83f6351ac104bb1e18256eb1a595024474dc584a78a8ff7f99e1fe29cc2b1f5da
7
- data.tar.gz: 707f51e7b7d17eb74e68589f4ab8efbc3b2d8bcaf6e3a81ebe7de4b17ac27378a3c86772b509093a0331a643e70d9ab24780e6ada855d81845dd4fec43a89a2e
6
+ metadata.gz: 0c9c890cd0810b7024f63886cc287afae42a61f35bc3d242418ac6df3940674355bb920344728bf726d94ababea5dc5d759a2afd573a3988c1d2e9d09281e912
7
+ data.tar.gz: 8a58d1766e222075acdf3302cc49f97a78abb5377c2d0cffdf88718e50527c8461b54025a5337bcd7fdb362ba5f57973548ad4e9601e18c80948cdea7e144a94
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sunspot_matchers (2.2.0.2)
4
+ sunspot_matchers (2.2.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -127,7 +127,7 @@ module SunspotMatchers
127
127
  class HaveSearchParams
128
128
  def initialize(method, *args, &block)
129
129
  @method = method
130
- @args = [*args, block].compact
130
+ @args = (block.nil? ? args : [*args, block])
131
131
  end
132
132
 
133
133
  def matches?(actual)
@@ -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].compact
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
@@ -1,3 +1,3 @@
1
1
  module SunspotMatchers
2
- VERSION = "2.2.0.2"
2
+ VERSION = "2.2.0.3"
3
3
  end
@@ -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.2
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-07-29 00:00:00.000000000 Z
11
+ date: 2015-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler