Skip to content
This repository
Browse code

! specs, were unclean

  • Loading branch information...
commit 9a0137efb4b74b762ffd21e88f1d7477f1cb1321 1 parent 96a5d6e
Florian R. Hanke authored

Showing 1 changed file with 23 additions and 19 deletions. Show diff stats Hide diff stats

  1. +23 19 server/spec/integration/sinatra_index_actions_spec.rb
42 server/spec/integration/sinatra_index_actions_spec.rb
@@ -5,54 +5,58 @@
5 5
6 6 describe 'Sinatra Index Actions' do
7 7
8   - # This is the application that is tested.
9   - #
10   - class MyPickyServer < Sinatra::Base
11   - extend Picky::Sinatra::IndexActions
  8 + before(:all) do
12 9
13   - data = Picky::Index.new :index do
14   - category :name
15   - category :surname
16   - end
  10 + # This is the application that is tested.
  11 + #
  12 + class MyIndexActionsPickyServer < Sinatra::Base
  13 + extend Picky::Sinatra::IndexActions
  14 +
  15 + data = Picky::Index.new :some_index_actions_index do
  16 + category :name
  17 + category :surname
  18 + end
17 19
18   - people = Picky::Search.new data
  20 + people = Picky::Search.new data
19 21
20   - get '/people' do
21   - results = people.search params[:query], params[:ids] || 20, params[:offset] || 0
22   - results.to_json
  22 + get '/people' do
  23 + results = people.search params[:query], params[:ids] || 20, params[:offset] || 0
  24 + results.to_json
  25 + end
23 26 end
  27 +
24 28 end
25 29
26 30 describe 'updating' do
27 31 before(:each) do
28 32 Picky::Indexes.clear
29 33 end
30   - let(:request) { ::Rack::MockRequest.new MyPickyServer }
  34 + let(:request) { ::Rack::MockRequest.new MyIndexActionsPickyServer }
31 35 it 'should update the index correctly' do
32   - request.post('/', params: { index: 'index', data: %Q{{ "id":"1", "name":"Florian", "surname":"Hanke" }} })
  36 + request.post('/', params: { index: 'some_index_actions_index', data: %Q{{ "id":"1", "name":"Florian", "surname":"Hanke" }} })
33 37
34 38 results = Yajl::Parser.parse request.get('/people', params: { query: 'florian' }).body
35 39 results['total'].should == 1
36 40
37   - request.post('/', params: { index: 'index', data: %Q{{ "id":"2", "name":"Florian", "surname":"Meier" }} })
  41 + request.post('/', params: { index: 'some_index_actions_index', data: %Q{{ "id":"2", "name":"Florian", "surname":"Meier" }} })
38 42
39 43 results = Yajl::Parser.parse request.get('/people', params: { query: 'florian' }).body
40 44 results['total'].should == 2
41 45 end
42 46 it 'should delete entries from the index correctly' do
43   - request.post('/', params: { index: 'index', data: %Q{{ "id":"1", "name":"Florian", "surname":"Hanke" }} })
44   - request.post('/', params: { index: 'index', data: %Q{{ "id":"2", "name":"Florian", "surname":"Meier" }} })
  47 + request.post('/', params: { index: 'some_index_actions_index', data: %Q{{ "id":"1", "name":"Florian", "surname":"Hanke" }} })
  48 + request.post('/', params: { index: 'some_index_actions_index', data: %Q{{ "id":"2", "name":"Florian", "surname":"Meier" }} })
45 49
46 50 results = Yajl::Parser.parse request.get('/people', params: { query: 'florian' }).body
47 51 results['total'].should == 2
48 52
49   - request.delete('/', params: { index: 'index', data: %Q{{ "id":"1" }} })
  53 + request.delete('/', params: { index: 'some_index_actions_index', data: %Q{{ "id":"1" }} })
50 54
51 55 results = Yajl::Parser.parse request.get('/people', params: { query: 'florian' }).body
52 56 results['total'].should == 1
53 57 end
54 58 it 'should have no problem with a superfluous delete' do
55   - request.delete('/', params: { index: 'index', data: %Q{{ "id":"1" }} })
  59 + request.delete('/', params: { index: 'some_index_actions_index', data: %Q{{ "id":"1" }} })
56 60
57 61 results = Yajl::Parser.parse request.get('/people', params: { query: 'florian' }).body
58 62 results['total'].should == 0

0 comments on commit 9a0137e

Please sign in to comment.
Something went wrong with that request. Please try again.