Class: SunspotMatchersTestunit::SunspotSessionSpy

Inherits:
Sunspot::Session
  • Object
show all
Defined in:
lib/sunspot_matchers_testunit/sunspot_session_spy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(original_session) ⇒ SunspotSessionSpy

Returns a new instance of SunspotSessionSpy.



20
21
22
23
24
# File 'lib/sunspot_matchers_testunit/sunspot_session_spy.rb', line 20

def initialize(original_session)
  @searches = []
  @original_session = original_session
  @config = Sunspot::Configuration.build
end

Instance Attribute Details

#current_search_classObject (readonly)

Returns the value of attribute current_search_class.



16
17
18
# File 'lib/sunspot_matchers_testunit/sunspot_session_spy.rb', line 16

def current_search_class
  @current_search_class
end

#original_sessionObject (readonly)

Returns the value of attribute original_session.



15
16
17
# File 'lib/sunspot_matchers_testunit/sunspot_session_spy.rb', line 15

def original_session
  @original_session
end

#searchesObject

Returns the value of attribute searches.



18
19
20
# File 'lib/sunspot_matchers_testunit/sunspot_session_spy.rb', line 18

def searches
  @searches
end

Instance Method Details

#build_search(*types, &block) ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
# File 'lib/sunspot_matchers_testunit/sunspot_session_spy.rb', line 82

def build_search(*types, &block)
  types.flatten!
  search = SunspotSearchSpy.new(
    nil,
    setup_for_types(types),
    Sunspot::Query::StandardQuery.new(types),
    @config
  )
  search.build(&block) if block
  search
end

#commitObject



68
69
# File 'lib/sunspot_matchers_testunit/sunspot_session_spy.rb', line 68

def commit
end

#commit_if_delete_dirtyObject



65
66
# File 'lib/sunspot_matchers_testunit/sunspot_session_spy.rb', line 65

def commit_if_delete_dirty
end

#commit_if_dirtyObject



62
63
# File 'lib/sunspot_matchers_testunit/sunspot_session_spy.rb', line 62

def commit_if_dirty
end

#delete_dirty?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/sunspot_matchers_testunit/sunspot_session_spy.rb', line 58

def delete_dirty?
  false
end

#dirty?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/sunspot_matchers_testunit/sunspot_session_spy.rb', line 54

def dirty?
  false
end

#index(*objects) ⇒ Object



30
31
# File 'lib/sunspot_matchers_testunit/sunspot_session_spy.rb', line 30

def index(*objects)
end

#index!(*objects) ⇒ Object



33
34
# File 'lib/sunspot_matchers_testunit/sunspot_session_spy.rb', line 33

def index!(*objects)
end

#inspectObject



26
27
28
# File 'lib/sunspot_matchers_testunit/sunspot_session_spy.rb', line 26

def inspect
  'Solr Search'
end

#new_search(*types, &block) ⇒ Object



75
76
77
78
79
80
# File 'lib/sunspot_matchers_testunit/sunspot_session_spy.rb', line 75

def new_search(*types, &block)
  types.flatten!
  search = build_search(*types, &block)
  @searches << [types, search]
  search
end

#remove(*objects) ⇒ Object



36
37
# File 'lib/sunspot_matchers_testunit/sunspot_session_spy.rb', line 36

def remove(*objects)
end

#remove!(*objects) ⇒ Object



39
40
# File 'lib/sunspot_matchers_testunit/sunspot_session_spy.rb', line 39

def remove!(*objects)
end

#remove_all(clazz = nil) ⇒ Object



48
49
# File 'lib/sunspot_matchers_testunit/sunspot_session_spy.rb', line 48

def remove_all(clazz = nil)
end

#remove_all!(clazz = nil) ⇒ Object



51
52
# File 'lib/sunspot_matchers_testunit/sunspot_session_spy.rb', line 51

def remove_all!(clazz = nil)
end

#remove_by_id(clazz, id) ⇒ Object



42
43
# File 'lib/sunspot_matchers_testunit/sunspot_session_spy.rb', line 42

def remove_by_id(clazz, id)
end

#remove_by_id!(clazz, id) ⇒ Object



45
46
# File 'lib/sunspot_matchers_testunit/sunspot_session_spy.rb', line 45

def remove_by_id!(clazz, id)
end

#search(*types, &block) ⇒ Object



71
72
73
# File 'lib/sunspot_matchers_testunit/sunspot_session_spy.rb', line 71

def search(*types, &block)
  new_search(*types, &block)
end

#setup_for_types(types) ⇒ Object



94
95
96
97
98
99
100
101
102
103
# File 'lib/sunspot_matchers_testunit/sunspot_session_spy.rb', line 94

def setup_for_types(types)
  if types.empty?
    raise(ArgumentError, "You must specify at least one type to search")
  end
  if types.length == 1
    Sunspot::Setup.for(types.first)
  else
    Sunspot::CompositeSetup.for(types)
  end
end