Skip to content
This repository
tag: v4.5.2
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 37 lines (29 sloc) 0.966 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
require 'picky'
require_relative 'model'

# This will output nothing on the first run,
# but the server will dump/reload even
# when stopping/starting.
#
p "Expected: Nothing, Nothing OR 1, 1"
p Model.search 'surname:mcnama*'
p Model.search 'picky'

picky = Model.new(name: 'Picky', surname: 'McNamara')
picky.save
florian = Model.new(name: 'Florian', surname: 'Hanke')
florian.save
tentacles = Model.new(name: 'Tentacles', surname: 'Jellyfish')
tentacles.save

p "Expected: 1, 2"
p Model.search 'surname:mcnama*'
p Model.search 'hanke'

florian.update_attributes! name: 'Kaspar', surname: 'Schiess'
tentacles.update_attributes! name: 'Roger', surname: 'Braun'

p "Expected: Nothing, 2, 3"
p Model.search 'hanke' # Not found anymore.
p Model.search 'surname:schies*'
p Model.search 'roger'

florian.destroy
tentacles.destroy

p "Expected: Nothing, Nothing"
p Model.search 'surname:schies*' # (Not found anymore)
p Model.search 'roger' # And out. (Not found anymore)
Something went wrong with that request. Please try again.