neo4j_test_server 1.0.0 → 1.1.1
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.
- checksums.yaml +4 -4
- data/README.md +14 -2
- data/VERSION +1 -1
- data/lib/neo4j_test_server.rb +6 -1
- data/lib/neo4j_test_server/installer.rb +36 -23
- data/lib/neo4j_test_server/neo4j_server.rb +2 -3
- data/neo4j_test_server.gemspec +3 -3
- data/spec/neo4j_test_server_spec.rb +12 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30bce83b04d5fd1b462bf8e95dbad3d6055d0609
|
4
|
+
data.tar.gz: fef78201629330e69da32f9f7cd7b3b3e546bbc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd6da5657dfeca44978240f290a83b3b50434bd100ae2737bbbc8ed2cfa06e4ab682b804347d48d4630bc51e951d68f42053ee2ac9e0bb8492f6f695c2507c67
|
7
|
+
data.tar.gz: f9f9e04205838bd0c317063436802c4b987477482db7ab58bd23555b45faa2c91770f97d22d9b19103803c8a45b02f16ce7cacb3054390df0e99bc2621121cc5
|
data/README.md
CHANGED
@@ -27,10 +27,13 @@ require 'sunspot_test/rspec'
|
|
27
27
|
This gem will automatically startup a Neo4j server running locally for testing purposes. The default server starts at
|
28
28
|
[http://localhost:7474](http://localhost:7474).
|
29
29
|
|
30
|
-
|
30
|
+
This gem also provides rspec hooks for tests that require Neo4j without requiring the server to be started for all of
|
31
31
|
your tests.
|
32
32
|
|
33
|
-
|
33
|
+
By default, the gem will download and run the "Community-2.2.0" version of Neo4j, see below for changing the edition
|
34
|
+
used.
|
35
|
+
|
36
|
+
## Writing tests that use Neo4jTestServer
|
34
37
|
|
35
38
|
In `spec_helper.rb`
|
36
39
|
```ruby
|
@@ -51,3 +54,12 @@ describe 'My Tests' do
|
|
51
54
|
end
|
52
55
|
end
|
53
56
|
```
|
57
|
+
|
58
|
+
## Using a different version of Neo4j
|
59
|
+
|
60
|
+
Before your tests run, call
|
61
|
+
```ruby
|
62
|
+
require 'neo4j_test_server'
|
63
|
+
|
64
|
+
Neo4jTestServer.edition = 'community-2.0.4' # Or whatever version you'd like to use
|
65
|
+
```
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.1.1
|
data/lib/neo4j_test_server.rb
CHANGED
@@ -9,6 +9,7 @@ module Neo4jTestServer
|
|
9
9
|
class << self
|
10
10
|
attr_writer :neo4j_startup_timeout
|
11
11
|
attr_writer :server
|
12
|
+
attr_accessor :edition
|
12
13
|
|
13
14
|
def neo4j_startup_timeout
|
14
15
|
@neo4j_startup_timeout ||= 30
|
@@ -54,7 +55,11 @@ module Neo4jTestServer
|
|
54
55
|
end
|
55
56
|
|
56
57
|
def server
|
57
|
-
@server ||= Neo4jTest::Server.new
|
58
|
+
@server ||= Neo4jTest::Server.new edition
|
59
|
+
end
|
60
|
+
|
61
|
+
def edition
|
62
|
+
@edition ||= 'community-2.2.0'
|
58
63
|
end
|
59
64
|
|
60
65
|
def session
|
@@ -24,7 +24,7 @@ module Neo4jTest
|
|
24
24
|
|
25
25
|
def download_to(edition = '')
|
26
26
|
# We want to ensure that we download the Neo4j archive to the gem location. Not the project's location
|
27
|
-
File.join(File.
|
27
|
+
File.join(File.expand_path('../../..', here), file_name(edition))
|
28
28
|
end
|
29
29
|
|
30
30
|
def download_url(edition)
|
@@ -52,36 +52,45 @@ module Neo4jTest
|
|
52
52
|
def unzip_neo4j(edition)
|
53
53
|
downloaded_file = download_to(edition)
|
54
54
|
|
55
|
+
clear_install_location
|
56
|
+
|
55
57
|
if OS::Underlying.windows?
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
58
|
+
unzip_for_windows downloaded_file, edition
|
59
|
+
else
|
60
|
+
unzip_for_unix downloaded_file, edition
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def unzip_for_windows(downloaded_file, edition)
|
65
|
+
# Extract and move to neo4j directory
|
66
|
+
unless File.exist?(install_location)
|
67
|
+
Zip::ZipFile.open(downloaded_file) do |zip_file|
|
68
|
+
zip_file.each do |f|
|
69
|
+
f_path = File.join('.', f.name)
|
70
|
+
FileUtils.mkdir_p(File.dirname(f_path))
|
71
|
+
begin
|
72
|
+
zip_file.extract(f, f_path) unless File.exist?(f_path)
|
73
|
+
rescue
|
74
|
+
puts "#{f.name} failed to extract."
|
67
75
|
end
|
68
76
|
end
|
69
|
-
FileUtils.mv "neo4j-#{edition}", install_location
|
70
|
-
end
|
71
|
-
|
72
|
-
# Install if running with Admin Privileges
|
73
|
-
if `reg query "HKU\\S-1-5-19"`.size > 0
|
74
|
-
`"#{install_location}/bin/neo4j install"`
|
75
|
-
puts 'Neo4j Installed as a service.'
|
76
77
|
end
|
78
|
+
FileUtils.mv "neo4j-#{edition}", install_location
|
79
|
+
end
|
77
80
|
|
78
|
-
|
79
|
-
|
80
|
-
`
|
81
|
-
puts 'Neo4j Installed
|
81
|
+
# Install if running with Admin Privileges
|
82
|
+
if `reg query "HKU\\S-1-5-19"`.size > 0
|
83
|
+
`"#{install_location}/bin/neo4j install"`
|
84
|
+
puts 'Neo4j Installed as a service.'
|
82
85
|
end
|
83
86
|
end
|
84
87
|
|
88
|
+
def unzip_for_unix(downloaded_file, edition)
|
89
|
+
`tar -xvf #{downloaded_file}`
|
90
|
+
`mv neo4j-#{edition} #{install_location}`
|
91
|
+
puts 'Neo4j Installed in to neo4j directory.'
|
92
|
+
end
|
93
|
+
|
85
94
|
def request_url(url)
|
86
95
|
status = HTTParty.head(url).code
|
87
96
|
fail "#{edition} is not available to download, try a different version" if status < 200 || status >= 300
|
@@ -99,6 +108,10 @@ module Neo4jTest
|
|
99
108
|
"#{path}/#{get_environment}"
|
100
109
|
end
|
101
110
|
|
111
|
+
def clear_install_location
|
112
|
+
FileUtils.rmtree(install_location)
|
113
|
+
end
|
114
|
+
|
102
115
|
def config_location
|
103
116
|
"#{install_location}/conf/neo4j-server.properties"
|
104
117
|
end
|
@@ -15,10 +15,9 @@ module Neo4jTest
|
|
15
15
|
|
16
16
|
attr_writer :neo4j_data_dir, :neo4j_home, :neo4j_jar, :bind_address, :port
|
17
17
|
|
18
|
-
def initialize(
|
18
|
+
def initialize(ed = 'community-2.2.0')
|
19
19
|
ensure_java_installed
|
20
|
-
self.edition =
|
21
|
-
super(*args)
|
20
|
+
self.edition = ed
|
22
21
|
end
|
23
22
|
|
24
23
|
def to_s
|
data/neo4j_test_server.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: neo4j_test_server 1.
|
5
|
+
# stub: neo4j_test_server 1.1.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "neo4j_test_server"
|
9
|
-
s.version = "1.
|
9
|
+
s.version = "1.1.1"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Swimminschrage"]
|
14
|
-
s.date = "2015-04-
|
14
|
+
s.date = "2015-04-21"
|
15
15
|
s.description = "Installs/Autostarts a Neo4j instance for your tests"
|
16
16
|
s.email = "Swimminschrage@gmail.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -33,6 +33,17 @@ describe 'Neo4jTest' do
|
|
33
33
|
expect { Neo4jTestServer.start_neo4j_server }.to raise_error(Neo4jTestServer::TimeoutError)
|
34
34
|
end
|
35
35
|
end
|
36
|
+
|
37
|
+
describe '#edition' do
|
38
|
+
it 'allows the user to specify the edition to install' do
|
39
|
+
edition = 'community-2.0.4'
|
40
|
+
allow(Neo4jTest::Installer).to receive(:bootstrap)
|
41
|
+
Neo4jTestServer.edition = edition
|
42
|
+
|
43
|
+
expect(Neo4jTest::Installer).to receive(:bootstrap).with('community-2.0.4')
|
44
|
+
Neo4jTestServer.server.bootstrap
|
45
|
+
end
|
46
|
+
end
|
36
47
|
end
|
37
48
|
|
38
49
|
describe '::Installer' do
|
@@ -105,7 +116,7 @@ describe 'Neo4jTest' do
|
|
105
116
|
|
106
117
|
it 'returns the correct save to location' do
|
107
118
|
allow(OS::Underlying).to receive(:windows?).and_return is_windows?
|
108
|
-
allow(Neo4jTest::Installer).to receive(:here).and_return("#{pwd}/test.rb")
|
119
|
+
allow(Neo4jTest::Installer).to receive(:here).and_return("#{pwd}/lib/anotherfolder/test.rb")
|
109
120
|
expect(Neo4jTest::Installer.download_to(edition)).to eq expected_download_to
|
110
121
|
end
|
111
122
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neo4j_test_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Swimminschrage
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: neo4j
|