Permalink
Browse files

! specs, were unclean

  • Loading branch information...
1 parent 96a5d6e commit 9a0137efb4b74b762ffd21e88f1d7477f1cb1321 @floere committed Mar 22, 2012
Showing with 23 additions and 19 deletions.
  1. +23 −19 server/spec/integration/sinatra_index_actions_spec.rb
View
42 server/spec/integration/sinatra_index_actions_spec.rb
@@ -5,54 +5,58 @@
describe 'Sinatra Index Actions' do
- # This is the application that is tested.
- #
- class MyPickyServer < Sinatra::Base
- extend Picky::Sinatra::IndexActions
+ before(:all) do
- data = Picky::Index.new :index do
- category :name
- category :surname
- end
+ # This is the application that is tested.
+ #
+ class MyIndexActionsPickyServer < Sinatra::Base
+ extend Picky::Sinatra::IndexActions
+
+ data = Picky::Index.new :some_index_actions_index do
+ category :name
+ category :surname
+ end
- people = Picky::Search.new data
+ people = Picky::Search.new data
- get '/people' do
- results = people.search params[:query], params[:ids] || 20, params[:offset] || 0
- results.to_json
+ get '/people' do
+ results = people.search params[:query], params[:ids] || 20, params[:offset] || 0
+ results.to_json
+ end
end
+
end
describe 'updating' do
before(:each) do
Picky::Indexes.clear
end
- let(:request) { ::Rack::MockRequest.new MyPickyServer }
+ let(:request) { ::Rack::MockRequest.new MyIndexActionsPickyServer }
it 'should update the index correctly' do
- request.post('/', params: { index: 'index', data: %Q{{ "id":"1", "name":"Florian", "surname":"Hanke" }} })
+ request.post('/', params: { index: 'some_index_actions_index', data: %Q{{ "id":"1", "name":"Florian", "surname":"Hanke" }} })
results = Yajl::Parser.parse request.get('/people', params: { query: 'florian' }).body
results['total'].should == 1
- request.post('/', params: { index: 'index', data: %Q{{ "id":"2", "name":"Florian", "surname":"Meier" }} })
+ request.post('/', params: { index: 'some_index_actions_index', data: %Q{{ "id":"2", "name":"Florian", "surname":"Meier" }} })
results = Yajl::Parser.parse request.get('/people', params: { query: 'florian' }).body
results['total'].should == 2
end
it 'should delete entries from the index correctly' do
- request.post('/', params: { index: 'index', data: %Q{{ "id":"1", "name":"Florian", "surname":"Hanke" }} })
- request.post('/', params: { index: 'index', data: %Q{{ "id":"2", "name":"Florian", "surname":"Meier" }} })
+ request.post('/', params: { index: 'some_index_actions_index', data: %Q{{ "id":"1", "name":"Florian", "surname":"Hanke" }} })
+ request.post('/', params: { index: 'some_index_actions_index', data: %Q{{ "id":"2", "name":"Florian", "surname":"Meier" }} })
results = Yajl::Parser.parse request.get('/people', params: { query: 'florian' }).body
results['total'].should == 2
- request.delete('/', params: { index: 'index', data: %Q{{ "id":"1" }} })
+ request.delete('/', params: { index: 'some_index_actions_index', data: %Q{{ "id":"1" }} })
results = Yajl::Parser.parse request.get('/people', params: { query: 'florian' }).body
results['total'].should == 1
end
it 'should have no problem with a superfluous delete' do
- request.delete('/', params: { index: 'index', data: %Q{{ "id":"1" }} })
+ request.delete('/', params: { index: 'some_index_actions_index', data: %Q{{ "id":"1" }} })
results = Yajl::Parser.parse request.get('/people', params: { query: 'florian' }).body
results['total'].should == 0

0 comments on commit 9a0137e

Please sign in to comment.