Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

moar test!

(disable client tests for now)
  • Loading branch information...
commit 732f0763660349547eff60004a11b0403438bee2 1 parent 2877ec7
Justin Hileman bobthecow authored
Showing with 67 additions and 31 deletions.
  1. +39 −3 spec/requests/api_spec.rb
  2. +28 −28 spec/requests/client_spec.rb
42 spec/requests/api_spec.rb
View
@@ -18,7 +18,7 @@
context 'servers' do
describe 'GET /servers' do
- it 'lists available servers' do
+ it 'always contains localhost' do
res = @api.get '/servers'
res.status.should eq 200
res.body.should match_json_expression \
@@ -36,8 +36,44 @@
end
describe 'POST /servers' do
- it 'creates a server when given a valid DSN'
- it 'returns 400 if the DSN is not valid'
+ it 'creates a server when given a valid DSN' do
+ res = @api.post do |req|
+ req.url '/servers'
+ req.headers['Content-Type'] = 'application/json'
+ req.body = { name: 'localhost:27017' }.to_json
+ end
+
+ res.status.should eq 200
+ res.headers['content-type'].should eq 'application/json'
+ res.body.should match_json_expression \
+ id: 'localhost',
+ name: 'localhost',
+ editable: true,
+ size: Fixnum,
+ count: Fixnum,
+ databases: Array
+ end
+
+ it 'returns 400 if the DSN is not valid' do
+ res = @api.post do |req|
+ req.url '/servers'
+ req.headers['Content-Type'] = 'application/json'
+ req.body = { name: 'http://foo/bar' }.to_json
+ end
+ res.status.should eq 400
+ end
+ end
+
+ describe 'DELETE /servers/:server' do
+ it 'deletes a server if it exists' do
+ res = @api.delete '/servers/localhost'
+ res.status.should eq 200
+ end
+
+ it 'returns 404 when the server is not found' do
+ res = @api.delete '/servers/not-a-real-server'
+ res.status.should eq 404
+ end
end
end
end
56 spec/requests/client_spec.rb
View
@@ -1,31 +1,31 @@
-require 'spec_helper'
+# require 'spec_helper'
-describe 'Genghis', :type => :request do
- it 'boots up' do
- visit '/'
- find('section#error').should_not be_visible
- find('aside#alerts').text.should be_empty
- page.should have_link 'Genghis'
- page.should have_link 'Justin Hileman'
- end
+# describe 'Genghis', :type => :request do
+# it 'boots up' do
+# visit '/'
+# find('section#error').should_not be_visible
+# find('aside#alerts').text.should be_empty
+# page.should have_link 'Genghis'
+# page.should have_link 'Justin Hileman'
+# end
- it 'starts at the server list' do
- visit '/'
- find('section#servers').should be_visible
- find('section#databases').should_not be_visible
- find('section#collections').should_not be_visible
- find('section#documents').should_not be_visible
- find('section#document').should_not be_visible
- end
+# it 'starts at the server list' do
+# visit '/'
+# find('section#servers').should be_visible
+# find('section#databases').should_not be_visible
+# find('section#collections').should_not be_visible
+# find('section#documents').should_not be_visible
+# find('section#document').should_not be_visible
+# end
- it 'has a magic button that shows and hides the "add server" form' do
- visit '/'
- within 'section#servers div.add-form' do
- find('input.name').should_not be_visible
- find('button.show').click
- find('input.name').should be_visible
- find('button.cancel').click
- find('input.name').should_not be_visible
- end
- end
-end
+# it 'has a magic button that shows and hides the "add server" form' do
+# visit '/'
+# within 'section#servers div.add-form' do
+# find('input.name').should_not be_visible
+# find('button.show').click
+# find('input.name').should be_visible
+# find('button.cancel').click
+# find('input.name').should_not be_visible
+# end
+# end
+# end
Please sign in to comment.
Something went wrong with that request. Please try again.