sunspot_matchers 2.0.0.2 → 2.0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sunspot_matchers (2.0.0.2)
4
+ sunspot_matchers (2.0.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -327,7 +327,7 @@ module SunspotMatchers
327
327
  def matches?(klass_or_object)
328
328
  @klass = klass_or_object.class.name == 'Class' ? klass_or_object : klass_or_object.class
329
329
  @sunspot = Sunspot::Setup.for(@klass)
330
- (@sunspot.all_text_fields + @sunspot.fields).collect(&:name).include?(@field)
330
+ @sunspot && (@sunspot.all_text_fields + @sunspot.fields).collect(&:name).include?(@field)
331
331
  end
332
332
 
333
333
  def description
@@ -335,7 +335,8 @@ module SunspotMatchers
335
335
  end
336
336
 
337
337
  def failure_message_for_should
338
- "expected class: #{@klass} to have searchable field: #{@field}"
338
+ message = "expected class: #{@klass} to have searchable field: #{@field}"
339
+ message << ", but Sunspot was not configured on #{@klass}" unless @sunspot
339
340
  end
340
341
 
341
342
  def failure_message_for_should_not
@@ -1,3 +1,3 @@
1
1
  module SunspotMatchers
2
- VERSION = "2.0.0.2"
2
+ VERSION = "2.0.0.3"
3
3
  end
@@ -0,0 +1,25 @@
1
+ require 'sunspot'
2
+ require 'sunspot_matchers'
3
+
4
+ describe SunspotMatchers::HaveSearchableField do
5
+ subject do
6
+ described_class.new(:field).tap do |matcher|
7
+ matcher.matches? klass
8
+ end
9
+ end
10
+
11
+ context "when a class has no searchable fields" do
12
+ let(:klass) { NotALotGoingOn = Class.new }
13
+
14
+ its(:failure_message_for_should) { should =~ /Sunspot was not configured/ }
15
+ end
16
+
17
+ context "when a class has an unexpected searchable field" do
18
+ let(:klass) { IndexedWithWrongThings = Class.new }
19
+ before do
20
+ Sunspot.setup(klass) { text :parachute }
21
+ end
22
+
23
+ its(:failure_message_for_should) { should_not =~ /Sunspot was not configured/ }
24
+ end
25
+ end
@@ -763,5 +763,9 @@ describe "Sunspot Matchers" do
763
763
  it "should fail if the model does not have the given field" do
764
764
  Post.should_not have_searchable_field(:potato)
765
765
  end
766
+
767
+ it "should fail if the model does not have any searchable fields" do
768
+ Person.should_not have_searchable_field(:name)
769
+ end
766
770
  end
767
771
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sunspot_matchers
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.2
4
+ version: 2.0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-26 00:00:00.000000000 Z
12
+ date: 2013-07-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -93,6 +93,7 @@ files:
93
93
  - lib/sunspot_matchers/sunspot_session_spy.rb
94
94
  - lib/sunspot_matchers/test_helper.rb
95
95
  - lib/sunspot_matchers/version.rb
96
+ - spec/have_searchable_field_matcher_spec.rb
96
97
  - spec/sunspot_matchers_spec.rb
97
98
  - sunspot_matchers.gemspec
98
99
  - test/sunspot_matchers_test.rb
@@ -111,7 +112,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
112
  version: '0'
112
113
  segments:
113
114
  - 0
114
- hash: -4036340369769902579
115
+ hash: -1436965995018875279
115
116
  required_rubygems_version: !ruby/object:Gem::Requirement
116
117
  none: false
117
118
  requirements: