mongo_browser 0.2.0.rc2 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +3 -1
- data/.rspec +1 -1
- data/.travis.yml +6 -1
- data/CHANGELOG.md +15 -0
- data/{grunt.js → Gruntfile.js} +10 -8
- data/Procfile +1 -0
- data/README.md +44 -2
- data/Rakefile +1 -12
- data/app/assets/images/ajax-loader.gif +0 -0
- data/app/assets/javascripts/app/controllers/{breadcrumbs.js.coffee → breadcrumbs_controller.js.coffee} +4 -7
- data/app/assets/javascripts/app/controllers/collections/index_controller.js.coffee +38 -0
- data/app/assets/javascripts/app/controllers/collections/stats_controller.js.coffee +17 -0
- data/app/assets/javascripts/app/controllers/{databases.js.coffee → databases/index_controller.js.coffee} +11 -15
- data/app/assets/javascripts/app/controllers/databases/stats_controller.js.coffee +15 -0
- data/app/assets/javascripts/app/controllers/documents/index_controller.js.coffee +54 -0
- data/app/assets/javascripts/app/controllers/documents/show_controller.js.coffee +38 -0
- data/app/assets/javascripts/app/controllers/main_controller.js.coffee +15 -0
- data/app/assets/javascripts/app/controllers/servers/show_controller.js.coffee +17 -0
- data/app/assets/javascripts/app/directives.js.coffee +23 -0
- data/app/assets/javascripts/app/filters.js.coffee +14 -1
- data/app/assets/javascripts/app/modules/alerts.js.coffee +58 -0
- data/app/assets/javascripts/app/modules/pager.js.coffee +2 -2
- data/app/assets/javascripts/app/modules/spinner.js.coffee +29 -0
- data/app/assets/javascripts/app/modules/table_filter.js.coffee +4 -4
- data/app/assets/javascripts/app/resources.js.coffee +14 -8
- data/app/assets/javascripts/app/services.js.coffee +11 -33
- data/app/assets/javascripts/application.js.coffee +62 -34
- data/app/assets/javascripts/application.test.js.coffee +5 -0
- data/app/assets/javascripts/compiled_templates.js.coffee +1 -0
- data/app/assets/javascripts/vendor.js.coffee +0 -1
- data/app/assets/stylesheets/application.css.scss +36 -18
- data/{public/index.html → app/views/index.erb} +8 -8
- data/bin/mongo_browser +2 -13
- data/config.ru +3 -1
- data/lib/mongo_browser.rb +1 -0
- data/lib/mongo_browser/api.rb +11 -0
- data/lib/mongo_browser/api/collections.rb +34 -0
- data/lib/mongo_browser/api/databases.rb +32 -0
- data/lib/mongo_browser/api/documents.rb +37 -0
- data/lib/mongo_browser/api/mongo.rb +41 -0
- data/lib/mongo_browser/application.rb +8 -174
- data/lib/mongo_browser/application/development.rb +32 -0
- data/lib/mongo_browser/cli.rb +48 -0
- data/lib/mongo_browser/entities.rb +43 -0
- data/lib/mongo_browser/models/collection.rb +7 -12
- data/lib/mongo_browser/models/document.rb +5 -1
- data/lib/mongo_browser/models/pager.rb +22 -9
- data/lib/mongo_browser/version.rb +1 -1
- data/mongo_browser.gemspec +22 -15
- data/package.json +30 -0
- data/public/ng/templates/alerts.html +6 -0
- data/public/ng/templates/collections/index.html +39 -0
- data/public/ng/templates/collections/stats.html +18 -0
- data/public/ng/templates/databases/index.html +35 -0
- data/public/ng/templates/databases/stats.html +18 -0
- data/public/ng/templates/documents/index.html +40 -0
- data/public/ng/templates/documents/show.html +17 -0
- data/{app/assets → public/ng}/templates/pager.html +0 -0
- data/{app/assets/templates/server_info.html → public/ng/templates/server/show.html} +1 -1
- data/{app/assets → public/ng}/templates/table_filter.html +0 -0
- data/script/ci_all +5 -1
- data/script/ci_e2e +5 -2
- data/script/ci_javascripts +1 -1
- data/script/ci_rspec +1 -1
- data/spec/javascripts/app/controllers/{breadcrumbs_spec.js.coffee → breadcrumbs_controller_spec.js.coffee} +1 -1
- data/spec/javascripts/app/controllers/collections/index_controller_spec.js.coffee +95 -0
- data/spec/javascripts/app/controllers/collections/stats_controller_spec.js.coffee +34 -0
- data/spec/javascripts/app/controllers/databases/index_controller_spec.js.coffee +93 -0
- data/spec/javascripts/app/controllers/databases/stats_controller_spec.js.coffee +30 -0
- data/spec/javascripts/app/controllers/documents/index_controller_spec.js.coffee +108 -0
- data/spec/javascripts/app/controllers/documents/show_controller_spec.js.coffee +94 -0
- data/spec/javascripts/app/controllers/{main_spec.js.coffee → main_controller_spec.js.coffee} +2 -2
- data/spec/javascripts/app/controllers/{server_info_spec.js.coffee → server/show_controller_spec.js.coffee} +5 -6
- data/spec/javascripts/app/directives_spec.js.coffee +108 -24
- data/spec/javascripts/app/filters_spec.js.coffee +31 -5
- data/spec/javascripts/app/modules/alerts_spec.js.coffee +138 -0
- data/spec/javascripts/app/modules/dialogs_spec.js.coffee +1 -2
- data/spec/javascripts/app/modules/pager_spec.js.coffee +0 -1
- data/spec/javascripts/app/modules/spinner_spec.js.coffee +65 -0
- data/spec/javascripts/app/modules/table_filter_spec.js.coffee +9 -9
- data/spec/javascripts/app/resources_spec.js.coffee +99 -0
- data/spec/javascripts/app/services_spec.js.coffee +31 -71
- data/spec/javascripts/config/{testacular-e2e.conf.js → karma-e2e.conf.js} +1 -1
- data/spec/javascripts/config/{testacular.conf.js → karma.conf.js} +2 -3
- data/spec/javascripts/e2e/collection_stats_scenario.js.coffee +12 -0
- data/spec/javascripts/e2e/collections_scenario.js.coffee +59 -20
- data/spec/javascripts/e2e/database_stats_scenario.js.coffee +11 -0
- data/spec/javascripts/e2e/databases_scenario.js.coffee +37 -36
- data/spec/javascripts/e2e/document_show_scenario.js.coffee +31 -0
- data/spec/javascripts/e2e/documents_pagination_scenario.js.coffee +33 -0
- data/spec/javascripts/e2e/documents_scenario.js.coffee +43 -4
- data/spec/javascripts/e2e/server_info_scenario.js.coffee +8 -2
- data/spec/javascripts/helpers/mocks.js.coffee +2 -0
- data/spec/javascripts/helpers_e2e/dsl.js.coffee +20 -0
- data/spec/javascripts/lib/angular-mocks.js +64 -16
- data/spec/javascripts/lib/angular-scenario.js +724 -561
- data/spec/javascripts/runner.html +5 -5
- data/spec/lib/api/collections_spec.rb +62 -0
- data/spec/lib/api/databases_spec.rb +58 -0
- data/spec/lib/api/documents_spec.rb +135 -0
- data/spec/lib/api/mongo_spec.rb +27 -0
- data/spec/lib/cli_spec.rb +19 -0
- data/spec/lib/entities_spec.rb +39 -0
- data/spec/lib/models/collection_spec.rb +16 -10
- data/spec/lib/models/database_spec.rb +4 -4
- data/spec/lib/models/document_spec.rb +5 -5
- data/spec/lib/models/pager_spec.rb +20 -11
- data/spec/spec_helper.rb +7 -15
- data/spec/support/api_example_group.rb +45 -0
- data/spec/support/fixtures.rb +10 -6
- data/spec/support/matchers/expose.rb +18 -0
- data/vendor/assets/javascripts/angular/angular-bootstrap.js +1 -1
- data/vendor/assets/javascripts/angular/angular-resource.js +78 -56
- data/vendor/assets/javascripts/angular/angular-sanitize.js +3 -1
- data/vendor/assets/javascripts/angular/angular.js +720 -404
- metadata +323 -183
- data/app/assets/javascripts/app.js.coffee +0 -8
- data/app/assets/javascripts/app/controllers.js.coffee +0 -2
- data/app/assets/javascripts/app/controllers/alerts.js.coffee +0 -12
- data/app/assets/javascripts/app/controllers/collections.js.coffee +0 -40
- data/app/assets/javascripts/app/controllers/documents.js.coffee +0 -49
- data/app/assets/javascripts/app/controllers/main.js.coffee +0 -10
- data/app/assets/javascripts/app/controllers/server_info.js.coffee +0 -14
- data/app/assets/javascripts/templates.js.coffee +0 -1
- data/app/assets/javascripts/templates/.gitkeep +0 -0
- data/app/assets/templates/collections.html +0 -53
- data/app/assets/templates/databases.html +0 -32
- data/app/assets/templates/documents.html +0 -45
- data/config-e2e.ru +0 -20
- data/spec/features/collections_list_spec.rb +0 -64
- data/spec/features/documents_list_spec.rb +0 -139
- data/spec/features/server_info_spec.rb +0 -23
- data/spec/javascripts/app/controllers/alerts_spec.js.coffee +0 -36
- data/spec/javascripts/app/controllers/collections_spec.js.coffee +0 -78
- data/spec/javascripts/app/controllers/databases_spec.js.coffee +0 -55
- data/spec/javascripts/app/controllers/documents_spec.js.coffee +0 -62
- data/spec/javascripts/helpers_e2e/app_element.js.coffee +0 -6
- data/spec/support/feature_example_group.rb +0 -53
- data/spec/support/matchers/have_flash_message.rb +0 -16
- data/spec/support/mongod.rb +0 -91
- data/spec/support/mongodb.conf +0 -47
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe "Server info", type: :request, js: true do
|
|
4
|
-
before do
|
|
5
|
-
visit "/"
|
|
6
|
-
|
|
7
|
-
within(".navbar") { click_link "Server Info" }
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
xit "has a valid title" do
|
|
11
|
-
within "h2" do
|
|
12
|
-
expect(page).to have_content("server info")
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
xit "displays information about the server" do
|
|
17
|
-
within "table" do
|
|
18
|
-
%w(version gitVersion sysInfo versionArray bits debug maxBsonObjectSize ok).each do |field|
|
|
19
|
-
expect(page).to have_content(field)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
describe "alerts", ->
|
|
2
|
-
beforeEach module("mb.controllers")
|
|
3
|
-
|
|
4
|
-
$scope = null
|
|
5
|
-
alerts = null
|
|
6
|
-
|
|
7
|
-
beforeEach inject ($injector, $rootScope, $controller) ->
|
|
8
|
-
$scope = $rootScope.$new()
|
|
9
|
-
|
|
10
|
-
alerts = $injector.get("alerts")
|
|
11
|
-
|
|
12
|
-
$controller "alerts",
|
|
13
|
-
$scope: $scope,
|
|
14
|
-
alerts: alerts
|
|
15
|
-
|
|
16
|
-
it "assings flash messages", ->
|
|
17
|
-
expect($scope.alertMessages).toBeDefined()
|
|
18
|
-
expect($scope.alertMessages).toEqual([])
|
|
19
|
-
|
|
20
|
-
alerts.info("Test message.")
|
|
21
|
-
expect($scope.alertMessages).toContain(id: 1, type: "info", text: "Test message.")
|
|
22
|
-
|
|
23
|
-
describe "#disposeAlert", ->
|
|
24
|
-
it "disposes an alert at the given index", ->
|
|
25
|
-
# Given
|
|
26
|
-
alerts.info("Information..")
|
|
27
|
-
alerts.error("Error..")
|
|
28
|
-
spyOn(alerts, "dispose").andCallThrough()
|
|
29
|
-
|
|
30
|
-
# When
|
|
31
|
-
$scope.disposeAlert(2)
|
|
32
|
-
|
|
33
|
-
# Then
|
|
34
|
-
expect(alerts.dispose).toHaveBeenCalledWith(2)
|
|
35
|
-
expect($scope.alertMessages).toContain(id: 1, type: "info", text: "Information..")
|
|
36
|
-
expect($scope.alertMessages).not.toContain(id: 2, type: "error", text: "Error..")
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
describe "collections", ->
|
|
2
|
-
beforeEach module("mb.controllers")
|
|
3
|
-
beforeEach module("mb.dialogs")
|
|
4
|
-
beforeEach module("mocks")
|
|
5
|
-
|
|
6
|
-
$scope = null
|
|
7
|
-
$httpBackend = null
|
|
8
|
-
alerts = null
|
|
9
|
-
|
|
10
|
-
beforeEach inject ($injector, $rootScope, $controller) ->
|
|
11
|
-
alerts = $injector.get("alerts")
|
|
12
|
-
|
|
13
|
-
$routeParams = $injector.get("$routeParams")
|
|
14
|
-
$routeParams.dbName = "test_database"
|
|
15
|
-
|
|
16
|
-
$httpBackend = $injector.get("$httpBackend")
|
|
17
|
-
$httpBackend.when("GET", "/api/databases/test_database/collections.json")
|
|
18
|
-
.respond([])
|
|
19
|
-
$httpBackend.when("GET", "/api/databases/test_database/stats.json")
|
|
20
|
-
.respond({})
|
|
21
|
-
|
|
22
|
-
$scope = $rootScope.$new()
|
|
23
|
-
$controller "collections",
|
|
24
|
-
$scope: $scope
|
|
25
|
-
|
|
26
|
-
$httpBackend.flush()
|
|
27
|
-
|
|
28
|
-
afterEach ->
|
|
29
|
-
$httpBackend.verifyNoOutstandingExpectation()
|
|
30
|
-
$httpBackend.verifyNoOutstandingRequest()
|
|
31
|
-
|
|
32
|
-
describe "#isLoading", ->
|
|
33
|
-
it "returns true when the resouce it loading", ->
|
|
34
|
-
$scope.loading = true
|
|
35
|
-
expect($scope.isLoading()).toBeTruthy()
|
|
36
|
-
|
|
37
|
-
it "otherwise returns false", ->
|
|
38
|
-
$scope.loading = false
|
|
39
|
-
expect($scope.isLoading()).toBeFalsy()
|
|
40
|
-
|
|
41
|
-
# TODO refactor this spec
|
|
42
|
-
describe "#delete", ->
|
|
43
|
-
collection = null
|
|
44
|
-
|
|
45
|
-
beforeEach ->
|
|
46
|
-
collection = dbName: "test_database", name: "dummy-collection-id"
|
|
47
|
-
|
|
48
|
-
it "shows a confirmation dialog", inject (dialogsHandler) ->
|
|
49
|
-
spyOn(dialogsHandler, "confirm")
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
$scope.delete(collection)
|
|
53
|
-
|
|
54
|
-
expect(dialogsHandler.confirm).toHaveBeenCalledWith \
|
|
55
|
-
"Deleting dummy-collection-id. Are you sure?",
|
|
56
|
-
jasmine.any(Function)
|
|
57
|
-
|
|
58
|
-
describe "when the dialog was confirmed", ->
|
|
59
|
-
beforeEach inject (dialogsHandler) ->
|
|
60
|
-
$httpBackend.when("DELETE", "/api/databases/test_database/collections.json?id=dummy-collection-id")
|
|
61
|
-
.respond([])
|
|
62
|
-
|
|
63
|
-
spyOn(alerts, "info")
|
|
64
|
-
$scope.delete(collection)
|
|
65
|
-
dialogsHandler.confirmed()
|
|
66
|
-
|
|
67
|
-
it "sends a delete request", ->
|
|
68
|
-
$httpBackend.flush()
|
|
69
|
-
|
|
70
|
-
it "displays a flash message", ->
|
|
71
|
-
$httpBackend.flush()
|
|
72
|
-
expect(alerts.info).toHaveBeenCalledWith("Collection dummy-collection-id has been deleted.")
|
|
73
|
-
|
|
74
|
-
describe "when the dialog was disposed", ->
|
|
75
|
-
it "does nothing", inject (dialogsHandler) ->
|
|
76
|
-
# When
|
|
77
|
-
$scope.delete(name: "dummy-collection-id")
|
|
78
|
-
dialogsHandler.disposed()
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
describe "databases", ->
|
|
2
|
-
beforeEach module("mb.controllers")
|
|
3
|
-
beforeEach module("mb.dialogs")
|
|
4
|
-
beforeEach module("mocks")
|
|
5
|
-
|
|
6
|
-
$scope = null
|
|
7
|
-
$httpBackend = null
|
|
8
|
-
alerts = null
|
|
9
|
-
|
|
10
|
-
beforeEach inject ($injector, $rootScope, $controller) ->
|
|
11
|
-
alerts = $injector.get("alerts")
|
|
12
|
-
|
|
13
|
-
$httpBackend = $injector.get("$httpBackend")
|
|
14
|
-
$httpBackend.when("GET", "/api/databases.json").respond([])
|
|
15
|
-
|
|
16
|
-
$scope = $rootScope.$new()
|
|
17
|
-
$controller "databases",
|
|
18
|
-
$scope: $scope
|
|
19
|
-
|
|
20
|
-
$httpBackend.flush()
|
|
21
|
-
|
|
22
|
-
afterEach ->
|
|
23
|
-
$httpBackend.verifyNoOutstandingExpectation()
|
|
24
|
-
$httpBackend.verifyNoOutstandingRequest()
|
|
25
|
-
|
|
26
|
-
# TODO rewrite this spec
|
|
27
|
-
describe "#delete", ->
|
|
28
|
-
it "shows a confirmation dialog", inject (dialogsHandler) ->
|
|
29
|
-
spyOn(dialogsHandler, "confirm")
|
|
30
|
-
$scope.delete(name: "test_database_name")
|
|
31
|
-
expect(dialogsHandler.confirm).toHaveBeenCalledWith \
|
|
32
|
-
"Deleting test_database_name. Are you sure?",
|
|
33
|
-
jasmine.any(Function)
|
|
34
|
-
|
|
35
|
-
describe "when the dialog was confirmed", ->
|
|
36
|
-
beforeEach inject (dialogsHandler) ->
|
|
37
|
-
$httpBackend.when("DELETE", "/api/databases.json?id=test_database_name")
|
|
38
|
-
.respond([])
|
|
39
|
-
|
|
40
|
-
spyOn(alerts, "info")
|
|
41
|
-
$scope.delete(name: "test_database_name")
|
|
42
|
-
dialogsHandler.confirmed()
|
|
43
|
-
|
|
44
|
-
it "sends a delete request", ->
|
|
45
|
-
$httpBackend.flush()
|
|
46
|
-
|
|
47
|
-
it "displays a flash message", ->
|
|
48
|
-
$httpBackend.flush()
|
|
49
|
-
expect(alerts.info).toHaveBeenCalledWith("Database test_database_name has been deleted.")
|
|
50
|
-
|
|
51
|
-
describe "when the dialog was disposed", ->
|
|
52
|
-
it "does nothing", inject (dialogsHandler) ->
|
|
53
|
-
# When
|
|
54
|
-
$scope.delete(name: "test_database_name")
|
|
55
|
-
dialogsHandler.disposed()
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
describe "documents", ->
|
|
2
|
-
beforeEach module("mb.controllers")
|
|
3
|
-
beforeEach module("mb.dialogs")
|
|
4
|
-
beforeEach module("mocks")
|
|
5
|
-
|
|
6
|
-
$scope = null
|
|
7
|
-
$httpBackend = null
|
|
8
|
-
alerts = null
|
|
9
|
-
|
|
10
|
-
beforeEach inject ($injector, $rootScope, $controller) ->
|
|
11
|
-
alerts = $injector.get("alerts")
|
|
12
|
-
|
|
13
|
-
$routeParams = $injector.get("$routeParams")
|
|
14
|
-
$routeParams.dbName = "test_database"
|
|
15
|
-
$routeParams.collectionName = "test_collection"
|
|
16
|
-
|
|
17
|
-
$httpBackend = $injector.get('$httpBackend')
|
|
18
|
-
$httpBackend.when("GET", "/api/databases/test_database/collections/test_collection/documents.json?page=1")
|
|
19
|
-
.respond([])
|
|
20
|
-
$httpBackend.when("GET", "/api/databases/test_database/collections/test_collection/stats.json")
|
|
21
|
-
.respond({})
|
|
22
|
-
|
|
23
|
-
$scope = $rootScope.$new()
|
|
24
|
-
$controller "documents",
|
|
25
|
-
$scope: $scope
|
|
26
|
-
|
|
27
|
-
$httpBackend.flush()
|
|
28
|
-
|
|
29
|
-
afterEach ->
|
|
30
|
-
$httpBackend.verifyNoOutstandingExpectation()
|
|
31
|
-
$httpBackend.verifyNoOutstandingRequest()
|
|
32
|
-
|
|
33
|
-
# TODO rewrite this spec
|
|
34
|
-
describe "#delete", ->
|
|
35
|
-
it "shows a confirmation dialog", inject (dialogsHandler) ->
|
|
36
|
-
spyOn(dialogsHandler, "confirm")
|
|
37
|
-
$scope.delete(id: "dummy-document-id")
|
|
38
|
-
expect(dialogsHandler.confirm).toHaveBeenCalledWith \
|
|
39
|
-
"Are you sure?",
|
|
40
|
-
jasmine.any(Function)
|
|
41
|
-
|
|
42
|
-
describe "when the dialog was confirmed", ->
|
|
43
|
-
beforeEach inject (dialogsHandler) ->
|
|
44
|
-
$httpBackend.when("DELETE", "/api/databases/test_database/collections/test_collection/documents.json?id=dummy-document-id")
|
|
45
|
-
.respond([])
|
|
46
|
-
|
|
47
|
-
spyOn(alerts, "info")
|
|
48
|
-
$scope.delete(id: "dummy-document-id")
|
|
49
|
-
dialogsHandler.confirmed()
|
|
50
|
-
|
|
51
|
-
it "sends a delete request", ->
|
|
52
|
-
$httpBackend.flush()
|
|
53
|
-
|
|
54
|
-
it "displays a flash message", ->
|
|
55
|
-
$httpBackend.flush()
|
|
56
|
-
expect(alerts.info).toHaveBeenCalledWith("Document dummy-document-id has been deleted.")
|
|
57
|
-
|
|
58
|
-
describe "when the dialog was disposed", ->
|
|
59
|
-
it "does nothing", inject (dialogsHandler) ->
|
|
60
|
-
# When
|
|
61
|
-
$scope.delete(id: "dummy-document-id")
|
|
62
|
-
dialogsHandler.disposed()
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
module FeatureExampleGroup
|
|
2
|
-
|
|
3
|
-
def fill_in_filter(value)
|
|
4
|
-
filter_input = find(%Q{form.filter input[type="text"]})
|
|
5
|
-
filter_input.set(value)
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def confirm_dialog(message = 'Are you sure?')
|
|
9
|
-
begin
|
|
10
|
-
wait_until { page.has_css?("div.bootbox.modal") }
|
|
11
|
-
rescue Capybara::TimeoutError
|
|
12
|
-
raise "Expected confirmation modal to be visible."
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
within "div.bootbox.modal" do
|
|
16
|
-
page.should have_content(message)
|
|
17
|
-
click_link "OK"
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
begin
|
|
21
|
-
wait_until { page.has_no_css?("div.bootbox.modal") }
|
|
22
|
-
rescue Capybara::TimeoutError
|
|
23
|
-
raise "Expected confirmation modal to be disposed."
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def should_hide_the_table_and_display_a_notification
|
|
28
|
-
expect(page).to_not have_css("table.databases")
|
|
29
|
-
expect(page).to have_content("Nothing has been found.")
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# Take a screenshot and html dump for the page
|
|
33
|
-
def capture_page(file_name = Time.now.to_i.to_s)
|
|
34
|
-
reports_path = File.expand_path("reports/capybara")
|
|
35
|
-
FileUtils.mkdir_p(reports_path)
|
|
36
|
-
|
|
37
|
-
file_path = File.join(reports_path, file_name)
|
|
38
|
-
|
|
39
|
-
captured_files = []
|
|
40
|
-
|
|
41
|
-
html_file = "#{file_path}.html"
|
|
42
|
-
File.open(html_file, "w") { |f| f.write(page.body) }
|
|
43
|
-
captured_files << html_file
|
|
44
|
-
|
|
45
|
-
if example.metadata[:js]
|
|
46
|
-
image_file = "#{file_path}.png"
|
|
47
|
-
page.driver.render(image_file, full: true)
|
|
48
|
-
captured_files << image_file
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
captured_files
|
|
52
|
-
end
|
|
53
|
-
end
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# Usage:
|
|
2
|
-
#
|
|
3
|
-
# describe "A feature" do
|
|
4
|
-
# specify { page.should have_flash_message("foo") }
|
|
5
|
-
# end
|
|
6
|
-
RSpec::Matchers.define :have_flash_message do |message|
|
|
7
|
-
match do
|
|
8
|
-
within "aside#alerts" do
|
|
9
|
-
page.should have_content(message)
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
description do
|
|
14
|
-
%Q{have the following flash message: "#{message.inspect}"}
|
|
15
|
-
end
|
|
16
|
-
end
|
data/spec/support/mongod.rb
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
require "singleton"
|
|
2
|
-
|
|
3
|
-
# Utility for run and manage test mongod instance.
|
|
4
|
-
class Mongod
|
|
5
|
-
include Singleton
|
|
6
|
-
|
|
7
|
-
MONGODB_DBPATH = "/tmp/mongo_browser/db"
|
|
8
|
-
# port for test mongod instance
|
|
9
|
-
MONGODB_PORT = 27018
|
|
10
|
-
|
|
11
|
-
attr_reader :pid
|
|
12
|
-
|
|
13
|
-
# Start test mongod instance
|
|
14
|
-
# * it cleans up the test server directory
|
|
15
|
-
# * starts a daemon
|
|
16
|
-
# * and wait until its fully responsive
|
|
17
|
-
def start!
|
|
18
|
-
return if running?
|
|
19
|
-
|
|
20
|
-
FileUtils.rm_rf(MONGODB_DBPATH) if Dir.exist?(MONGODB_DBPATH)
|
|
21
|
-
FileUtils.mkdir_p(MONGODB_DBPATH)
|
|
22
|
-
|
|
23
|
-
@pid = Mongod.start
|
|
24
|
-
wait_until_responsive
|
|
25
|
-
|
|
26
|
-
yield MONGODB_PORT if block_given?
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# Kills test mongod instance
|
|
30
|
-
def shutdown!
|
|
31
|
-
puts "shutdown! test mongod instance"
|
|
32
|
-
return unless running?
|
|
33
|
-
|
|
34
|
-
Process.kill('HUP', pid)
|
|
35
|
-
|
|
36
|
-
@pid = nil
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
# Returns true is mongodb server is ready to use
|
|
40
|
-
def responsive?
|
|
41
|
-
Mongo::Connection.new(MongoBrowser::DEFAULT_MONGODB_HOST, MONGODB_PORT)
|
|
42
|
-
true
|
|
43
|
-
rescue Mongo::ConnectionFailure
|
|
44
|
-
false
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def running?
|
|
48
|
-
not pid.nil?
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
private
|
|
52
|
-
|
|
53
|
-
class << self
|
|
54
|
-
|
|
55
|
-
# Check whether port for test mongod is available,
|
|
56
|
-
def test_port_available?
|
|
57
|
-
begin
|
|
58
|
-
server = TCPServer.new(MongoBrowser::DEFAULT_MONGODB_HOST, MONGODB_PORT)
|
|
59
|
-
true
|
|
60
|
-
rescue
|
|
61
|
-
false
|
|
62
|
-
end
|
|
63
|
-
ensure
|
|
64
|
-
server.close if server
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
# Starts a core MongoDB test daemon.
|
|
68
|
-
def start
|
|
69
|
-
raise "port #{MONGODB_PORT} is not available" unless test_port_available?
|
|
70
|
-
|
|
71
|
-
command = "mongod --config #{File.expand_path("spec/support/mongodb.conf")}"
|
|
72
|
-
log_file = File.open(File.expand_path("log/test_mongod.log"), "w")
|
|
73
|
-
|
|
74
|
-
Process.spawn(command, out: log_file)
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
# Uses exponential back-off technique for waiting for the mongodb server
|
|
79
|
-
def wait_until_responsive
|
|
80
|
-
wait_time = 0.01
|
|
81
|
-
start_time = Time.now
|
|
82
|
-
timeout = 10
|
|
83
|
-
|
|
84
|
-
until responsive?
|
|
85
|
-
raise "Could not start mongod after #{timeout} seconds" if Time.now - start_time >= timeout
|
|
86
|
-
|
|
87
|
-
sleep wait_time
|
|
88
|
-
wait_time *= 2
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
end
|
data/spec/support/mongodb.conf
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# mongodb.conf
|
|
2
|
-
|
|
3
|
-
# Where to store the data.
|
|
4
|
-
|
|
5
|
-
# Note: if you run mongodb as a non-root user (recommended) you may
|
|
6
|
-
# need to create and set permissions for this directory manually,
|
|
7
|
-
# e.g., if the parent directory isn't mutable by the mongodb user.
|
|
8
|
-
dbpath=/tmp/mongo_browser/db
|
|
9
|
-
|
|
10
|
-
#where to log
|
|
11
|
-
logpath=/tmp/mongo_browser/db.log
|
|
12
|
-
|
|
13
|
-
logappend=true
|
|
14
|
-
|
|
15
|
-
port = 27018
|
|
16
|
-
|
|
17
|
-
# Disables write-ahead journaling
|
|
18
|
-
nojournal = true
|
|
19
|
-
|
|
20
|
-
# Turn on/off security. Off is currently the default
|
|
21
|
-
noauth = true
|
|
22
|
-
auth = true
|
|
23
|
-
|
|
24
|
-
# Verbose logging output.
|
|
25
|
-
verbose = true
|
|
26
|
-
|
|
27
|
-
# Inspect all client data for validity on receipt (useful for
|
|
28
|
-
# developing drivers)
|
|
29
|
-
objcheck = true
|
|
30
|
-
|
|
31
|
-
# Set oplogging level where n is
|
|
32
|
-
# 0=off (default)
|
|
33
|
-
# 1=W
|
|
34
|
-
# 2=R
|
|
35
|
-
# 3=both
|
|
36
|
-
# 7=W+some reads
|
|
37
|
-
diaglog = 3
|
|
38
|
-
|
|
39
|
-
# Disable the HTTP interface (Defaults to localhost:28017).
|
|
40
|
-
nohttpinterface = true
|
|
41
|
-
|
|
42
|
-
# Turns off server-side scripting. This will result in greatly limited
|
|
43
|
-
# functionality
|
|
44
|
-
noscripting = true
|
|
45
|
-
|
|
46
|
-
# Disable data file preallocation.
|
|
47
|
-
#noprealloc = true
|