genghisapp 2.0.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,79 @@
1
+ require 'spec_helper'
2
+ require 'faraday'
3
+
4
+ describe 'Genghis API', :type => :request do
5
+ before :all do
6
+ @api = Faraday.new url: "http://localhost:#{@genghis_port}"
7
+ @api.headers['Accept'] = 'application/json'
8
+ @api.headers['Content-Type'] = 'application/json'
9
+ end
10
+
11
+ it 'boots up' do
12
+ res = @api.get '/check-status'
13
+ res.status.should eq 200
14
+ res.body.should match_json_expression({
15
+ alerts: []
16
+ })
17
+ end
18
+
19
+ context 'servers' do
20
+ describe 'GET /servers' do
21
+ it 'always contains localhost' do
22
+ res = @api.get '/servers'
23
+ res.status.should eq 200
24
+ res.body.should match_json_expression \
25
+ [
26
+ {
27
+ id: 'localhost',
28
+ name: 'localhost',
29
+ editable: true,
30
+ size: Fixnum,
31
+ count: Fixnum,
32
+ databases: Array
33
+ }
34
+ ].ignore_extra_values!
35
+ end
36
+ end
37
+
38
+ describe 'POST /servers' do
39
+ it 'creates a server when given a valid DSN' do
40
+ res = @api.post do |req|
41
+ req.url '/servers'
42
+ req.headers['Content-Type'] = 'application/json'
43
+ req.body = { name: 'localhost:27017' }.to_json
44
+ end
45
+
46
+ res.status.should eq 200
47
+ res.headers['content-type'].should eq 'application/json'
48
+ res.body.should match_json_expression \
49
+ id: 'localhost',
50
+ name: 'localhost',
51
+ editable: true,
52
+ size: Fixnum,
53
+ count: Fixnum,
54
+ databases: Array
55
+ end
56
+
57
+ it 'returns 400 if the DSN is not valid' do
58
+ res = @api.post do |req|
59
+ req.url '/servers'
60
+ req.headers['Content-Type'] = 'application/json'
61
+ req.body = { name: 'http://foo/bar' }.to_json
62
+ end
63
+ res.status.should eq 400
64
+ end
65
+ end
66
+
67
+ describe 'DELETE /servers/:server' do
68
+ it 'deletes a server if it exists' do
69
+ res = @api.delete '/servers/localhost'
70
+ res.status.should eq 200
71
+ end
72
+
73
+ it 'returns 404 when the server is not found' do
74
+ res = @api.delete '/servers/not-a-real-server'
75
+ res.status.should eq 404
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,31 @@
1
+ # require 'spec_helper'
2
+
3
+ # describe 'Genghis', :type => :request do
4
+ # it 'boots up' do
5
+ # visit '/'
6
+ # find('section#error').should_not be_visible
7
+ # find('aside#alerts').text.should be_empty
8
+ # page.should have_link 'Genghis'
9
+ # page.should have_link 'Justin Hileman'
10
+ # end
11
+
12
+ # it 'starts at the server list' do
13
+ # visit '/'
14
+ # find('section#servers').should be_visible
15
+ # find('section#databases').should_not be_visible
16
+ # find('section#collections').should_not be_visible
17
+ # find('section#documents').should_not be_visible
18
+ # find('section#document').should_not be_visible
19
+ # end
20
+
21
+ # it 'has a magic button that shows and hides the "add server" form' do
22
+ # visit '/'
23
+ # within 'section#servers div.add-form' do
24
+ # find('input.name').should_not be_visible
25
+ # find('button.show').click
26
+ # find('input.name').should be_visible
27
+ # find('button.cancel').click
28
+ # find('input.name').should_not be_visible
29
+ # end
30
+ # end
31
+ # end
@@ -0,0 +1,28 @@
1
+ require 'rspec/autorun'
2
+ require 'capybara/rspec'
3
+ require 'capybara/poltergeist'
4
+ require 'json_expressions/rspec'
5
+ require 'net/http'
6
+
7
+ Capybara.default_driver = :poltergeist
8
+ Capybara.run_server = false
9
+
10
+ RSpec.configure do |config|
11
+ def find_available_port
12
+ server = TCPServer.new('127.0.0.1', 0)
13
+ server.addr[1]
14
+ ensure
15
+ server.close if server
16
+ end
17
+
18
+ config.before :all do
19
+ @genghis_port = find_available_port
20
+ @genghis_pid = spawn 'php', '-S', "localhost:#{@genghis_port}", 'genghis.php', :out => '/dev/null'
21
+ Capybara.app_host = "http://localhost:#{@genghis_port}"
22
+ sleep 0.1
23
+ end
24
+
25
+ config.after :all do
26
+ Process.kill('HUP', @genghis_pid)
27
+ end
28
+ end
metadata ADDED
@@ -0,0 +1,267 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: genghisapp
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0.rc.1
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Justin Hileman
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: vegas
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.1.8
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.1.8
30
+ - !ruby/object:Gem::Dependency
31
+ name: sinatra
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 1.3.3
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.3.3
46
+ - !ruby/object:Gem::Dependency
47
+ name: sinatra-contrib
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.3.1
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.3.1
62
+ - !ruby/object:Gem::Dependency
63
+ name: sinatra-mustache
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 0.0.4
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 0.0.4
78
+ - !ruby/object:Gem::Dependency
79
+ name: mongo
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 1.7.0
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 1.7.0
94
+ - !ruby/object:Gem::Dependency
95
+ name: json
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 1.7.0
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 1.7.0
110
+ - !ruby/object:Gem::Dependency
111
+ name: rake
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: active_support
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: therubyracer
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: less
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ - !ruby/object:Gem::Dependency
175
+ name: rainpress
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ type: :development
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ - !ruby/object:Gem::Dependency
191
+ name: uglifier
192
+ requirement: !ruby/object:Gem::Requirement
193
+ none: false
194
+ requirements:
195
+ - - ! '>='
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
198
+ type: :development
199
+ prerelease: false
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ! '>='
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
+ - !ruby/object:Gem::Dependency
207
+ name: html_compressor
208
+ requirement: !ruby/object:Gem::Requirement
209
+ none: false
210
+ requirements:
211
+ - - ! '>='
212
+ - !ruby/object:Gem::Version
213
+ version: '0'
214
+ type: :development
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ! '>='
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
222
+ description: ! ' Genghis is a single-file MongoDB admin app, made entirely out
223
+ of awesome.
224
+
225
+ '
226
+ email: justin@justinhileman.info
227
+ executables:
228
+ - genghisapp
229
+ extensions: []
230
+ extra_rdoc_files: []
231
+ files:
232
+ - LICENSE
233
+ - README.markdown
234
+ - CHANGELOG.markdown
235
+ - genghis.rb
236
+ - bin/genghisapp
237
+ - spec/requests/api_spec.rb
238
+ - spec/requests/client_spec.rb
239
+ - spec/spec_helper.rb
240
+ homepage: http://genghisapp.com
241
+ licenses: []
242
+ post_install_message:
243
+ rdoc_options: []
244
+ require_paths:
245
+ - .
246
+ required_ruby_version: !ruby/object:Gem::Requirement
247
+ none: false
248
+ requirements:
249
+ - - ! '>='
250
+ - !ruby/object:Gem::Version
251
+ version: '0'
252
+ required_rubygems_version: !ruby/object:Gem::Requirement
253
+ none: false
254
+ requirements:
255
+ - - ! '>='
256
+ - !ruby/object:Gem::Version
257
+ version: 1.3.6
258
+ requirements: []
259
+ rubyforge_project: genghisapp
260
+ rubygems_version: 1.8.23
261
+ signing_key:
262
+ specification_version: 3
263
+ summary: The single-file MongoDB admin app
264
+ test_files:
265
+ - spec/requests/api_spec.rb
266
+ - spec/requests/client_spec.rb
267
+ - spec/spec_helper.rb